pysimplegui popup button_justification problem - python

According to the documentation of PySimpleGUI, the popup element should have an argument called button_justification, which position the button in 'right' or 'left', or 'center' within the popup window.
When i added button_justification='center' to the popup element in my project it raised the error: popup() got an unexpected keyword argument 'button_justification'. What's the problem?
Image

Not all enhancements added into the PyPI version.
Download from GitHub
There is code in the PySimpleGUI package that upgrades your previously pip installed package to the latest version checked into GitHub.
You can use the commands psgmain to run the test harness or psgupgrade to invoke the GitHub upgrade code.
or, you can call sg.main(), like
d:\>python
Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import PySimpleGUI as sg
>>> sg.main()

Related

Trying to use win32ui with pywin32 gives: A dynamic link library (DLL) initialization routine failed

I am trying to use the win32ui module from pywin32 (yes i have the correct version).
My win32gui module does work fine but the ui module give me and error.
I have already tried:
reinstalling python,
adding PYTHON_PATH too system vars,
running the after install pywin32 script,
For the rest I am kinda of out thing i can try to do.
Python version: 3.9 (64 bit)
Pywin32 version: pywin32-228.win-amd64-py3.9 (is the .exe file name i don't know how to find the version)
just to clear up my only code is:
import win32ui
(this is my first question so i hope i have done this right)
Update
Applied the (below) fix (and a couple of more) to the original sources, built them, and uploaded the .whls to [GitHub]: CristiFati/Prebuilt-Binaries - (master) Prebuilt-Binaries/PyWin32/v228. But, since this bug is kind of a "deal breaker" (and there are 4+ months since v228 was released), I'm expecting v229 very soon (in the next days or so).
Check the Install steps section from (the beginning of) [SO]: PyWin32 and Python 3.8.0 (#CristiFati's answer) for details on how to install the .whls.
It's constantly reproducible on:
Python 3.9 64bit and 32bit (works on older versions)
PyWin32 228 (and older)
[cfati#CFATI-5510-0:e:\Work\Dev\GitHub\CristiFati\pywin32\src]> sopr.bat
### Set shorter prompt to better fit when pasted in StackOverflow (or other) pages ###
[prompt]> "e:\Work\Dev\VEnvs\py_pc064_03.09.00_test0\Scripts\python.exe"
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32ui
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\Install\pc064\Python\Python\03.09.00\Lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 1114] A dynamic link library (DLL) initialization routine failed
>>> import win32api
I did some debugging (created a VStudio 2015 solution (with 2 projects: for Python 3.9 and Python 3.8) for win32ui), and it turns out it's an Access Violation (segfault). The "best" part is that it's occurring before DllMain.
One of the last lines that I could get the debugger in, was [GitHub]: mhammond/pywin32 - (b228) pywin32/Pythonwin/win32RichEdit.cpp#225:
PyCCtrlView_Type PyCRichEditView::type("PyCRichEditView", &PyCCtrlView::type, &PyCRichEditCtrl::type,
RUNTIME_CLASS(CRichEditView), sizeof(PyCRichEditView),
PYOBJ_OFFSET(PyCRichEditView), PyCRichEditView_methods,
GET_PY_CTOR(PyCRichEditView));
This is a static member. Since the 2nd and 3rd arguments are also static members (wasn't paying attention to the fact that they're pointers), I thought it was [ISOCPP]: What’s the “static initialization order ‘fiasco’ (problem)”?, and I chased some ghosts.
Anyway, today I noticed [GitHub]: mhammond/pywin32 - Ensure we hold the GIL as win32ui initializes and calls back into Python (and from there [GitHub]: mhammond/pywin32 - Import win32ui broken on Python 3.9 that it's addressing).
Applying the patch, fixes the problem:
[prompt]> "e:\Work\Dev\VEnvs\py_pc064_03.09.00_test0\Scripts\python.exe"
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32ui
>>> import win32api

Python3.6 use font awesome icons

I am searching how can i use font-awesome icons to a Tkinter python application.
Here is what i tried:
https://fontawesome.com/icons/tree?style=solid
pip3 install fontawesome
Python 3.6.9 (default, May 23 2020, 00:01:58)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import fontawesome as fa
>>> print(fa.icons['tree'])

>>>
I know that i must download icons - map (i do it in the past) but i don't find now how.
Thanks in advance
Edit: Same question before 26 days: FontAwesome with Python
If you want to see actual icons on your shell you need to install fontawesome's font on your computer and configure your terminal emulator to use this font.
Fontawesome the font is a font, but instead of just letters it also got icons.
fontawesome the python library is just dictionary with the icon's name as key and the character as value. But you can see the actual caractere only if you install Fontawesome the font.

Matplotlib : cannot turn off interactive mode in spyder

From doc about interactive mode
With this code :
import matplotlib.pyplot as plt
plt.ioff()
plt.plot([1.6, 2.7])
plt.show()
show() call should block until I close the graph. But it doesn't, show() does not block execution. I can add some code to IPython shell while my figure still displayed.
Python 3.7.0 (default, Jun 28 2018, 08:04:48) [MSC v.1912 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 6.5.0 -- An enhanced Interactive Python.
My backend is 'Qt5Agg'
I tested this code on another python env (from Cygwin): it works flawlessly.
You can turn off support for matplotlib via
Tools/Preferences/IPython Console/Graphics/Support for graphics(Matplotlib)/Activate support

Python webbrowser - registering browsers on Windows

I'm trying to register the Firefox browser to run on Windows. According to the documentation for Webbrowser, "If the environment variable BROWSER exists, it is interpreted to override the platform default list of browsers, as a os.pathsep-separated list of browsers to try in order". I tried setting it, but it had no impact.
Z:\>SET BROWSER=C:\Program Files (x86)\Mozilla Firefox\firefox.exe %s
Z:\>python3
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (I
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import webbrowser
>>>
>>> webbrowser.open('http://google.com')
True
>>>
webbrowser.get("firefox") doesn't work either
How can I make webbrowser launch Firefox?
You might need to set static envionment viraibles, this you can do in the properties of my computer... Whether or not it will help is for you to figure out (worked over here..).
Another way to do this:
import webbrowser
webbrowser.get("open -a C:\\Program F~\\Mozilla Firefox\\firefox.exe %s")
webbrowser.open('http://google.com')

Problem executing with Python+MySQL

I am not getting the reason why my python script is not working though I hv put all the things correctly as my knowledge.The below test I did and it worked fine.But when I import the MySQLdb in my script it gives error as no module name MySQLdb.
**C:\Python26>python
Python 2.6.1 (r261:67517, Dec 4 2008, 16:51:00) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
import MySQLdb
**
Kindly let me know the reason for this error.
And all the development is going on in windows XP, python 2.6, mysql 4.0.3
Earlier 1 hour back I have posted the question but some mistake was there in the question itself..
seems like the path is not set properly.

Categories