wxPython | Python GUI programming examples
kandi X-RAY | wxPython Summary
kandi X-RAY | wxPython Summary
wxPython is a Python extension library for developing cross platform GUI. It is an alternative to other GUI development toolkits like PyQt, Tkinter etc. This repostiory contains a variety of code examples for developing different GUI elements with wxPython.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Clipboard event handler
- Draw the graph
- Update the data
- Convert polar coordinates to cartesian coordinates
- Event handler for the page
- Calculates the layout
- Calculates the scale of the DC
- Open file dialog
- Open the sketch file
- File save event handler
- Creates a button bar
- Right click event handler
- Mouse event handler
- Pickness event handler
- Creates a button
- Event handler for other color dialog
- Double click handler
- Event handler for start button
- Start key event handler
- Creates a wx MenuBar
- Calculate the total number of pages
- Creates the toolbar
- Left down event handler
- Color event handler
- Timeout event handler
- Paste event handler
wxPython Key Features
wxPython Examples and Code Snippets
Community Discussions
Trending Discussions on wxPython
QUESTION
I have a wxPython application and I load an icon on the main form in the code like below
...ANSWER
Answered 2022-Mar-12 at 07:52You are reinventing the wheel.
wxpython
has a facility for incorporating png
images into a python module.
You may then access them as an image, a bitmap or an icon.
https://docs.wxpython.org/wx.tools.img2py.html#module-wx.tools.img2py
Here is the code I use in a Linux project, adapt as necessary:
QUESTION
I'm trying to display an image on the screen, without any window/application popping up/containing it. I'm pretty close with TKinter, but the method for removing the background color of the canvas is hacky and has some undesired effects.
...ANSWER
Answered 2022-Mar-10 at 14:24So, is there a way to draw an image on the screen without any background at all with Python?
Using Tkinter, for this image, no, you cannot achieve the desired result. (You can look for other modules like 'PyQT5', 'Kivy', 'wxPython', or 'turtle' maybe.)
See, transparentcolor
Specifies the transparent color index of the toplevel.
If you want to do the best in Tkinter, here are some changes to your code:
QUESTION
I have installed:
- Python 3.10.1
- PyCharm Community 2021.3
- Visual Studio Build Tools 2022, including:
- C++ Build Tools Core Features
- C++ 2022 Redistributable Update
- C++ core desktop features
- MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)
- Windows 10 SDK (10.0.19041.0)
- C++ CMake tools for Windows
- Testing tools core features - Build Tools
- C++ AddressSanitizer
- C++/CLI support for v143 build tools (Latest)
- C++ Modules for v143 build tools (x64/x86 - experimental)
When trying to install wxPython in my project's virtualenv, I get this error:
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.2 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
Both the error and anything I can find on the internet (including here) tells me to download C++ build tools and install C++ 14.2 or greater / the latest version. I have:
- done that (see the list above),
- rebooted
venv/Scripts/pip install --upgrade setuptools
venv/Scripts/pip install --upgrade wheel
venv/Scripts/pip install --upgrade pip
What am I missing here? Is there some sort of path variable that I need to configure somewhere so pip/wheel/setuptools knows where to find the compiler?
...ANSWER
Answered 2021-Dec-15 at 10:55I have the same problem. Solved for me to use Python 3.9.9. Its maybe about a distutils problem in Python 3.10.1 with this warning from msvc9compiler.py:
DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12
This leads to:
raise DistutilsPlatformError("Unable to find vcvarsall.bat")
QUESTION
I'm using Python3, wxPython 4 on MacBook Air M1, macOS Big Sur. I found the SetBackgroundColour method doesn't work, (but when I call item.SetText("888"), the text has been successfully updated ) Does anyone know the reason? Thanks!
...ANSWER
Answered 2022-Jan-11 at 20:37I've revisited this because your code does some fiddling about, which I didn't take into consideration.
I've also addressed the Deprecation warnings you would have been getting.
In short, access the item via the ListCtrl
and use the index
.
QUESTION
I'm a beginner in WxPython and I've tried experimenting splitting up the code to make it organized and look neater. I've tried it with simple code but it doesn't work. Can anyone please give me a hand?
The code I've tried:
...ANSWER
Answered 2021-Dec-14 at 10:55For want of a nail the kingdom was lost
You are missing a __
Without the init
, nothing occurs when you call text_ctrl
QUESTION
I am writing a Python 3.9 GUI application using wxPython. The application allows the user to enter information and press a "calculate" button. This will kick of a long running thread that updates the main application window with status updates. The application successfully kicks off the calculation thread and remains responsive.
Now I would like to add an "abort" button that will stop/cancel/abort the previously started thread when the users chooses to press the "abort" button.
After looking for some time, I found the code below on the wxPython website that has the general framework I am looking for. It follows the main logic of my application in a more simple form. It is missing the ongoing GUI status update, so I made a single addition to simulate the GUI status updates - see "<<<<<<" reference in the code below.
wx.PostEvent(self._notify_window, ResultEvent(i))
However, after adding this line it seems to break the event handling when the user is pressing the "stop" button while the processing thread has started. When pressing the "stop" button after 3-4 seconds, the counting thread in the sample code below continues to run and is ignoring the "stop" button event.
When this line is removed, the "stop" feature in the example code below works and the loop is disrupted.
How can I keep the feature of updating the GUI with status updates while the counting thread is running and also have the "stop" button terminate the actively running thread?
I am sure there are ways to optimize the code below. Please don't hesitate to share your thoughts/knowledge. Thank you.
...ANSWER
Answered 2021-Nov-19 at 19:49You are simply setting self.worker = None
at the wrong point.
It should only be set to None
on Stop or when it terminates naturally, other than that the code is fine.
e.g.
QUESTION
I'm trying to make a help menu in wxPython that has a tree control on the left and an html viewer on the right; the treecontrol acts as a sort of navigation menu, and on clicking an item in the treecontrol, the appropriate local .html file should load in the left panel.
However, when I try to implement this, I'm unable to bind any events to the different nodes in the tree control. This is what I have so far -- could someone show me where I'm going wrong?
Code:
...ANSWER
Answered 2021-Nov-02 at 08:40Here's a mock-up of your code, which I've adapted to use the labels in the treectrl to decide what to display.
QUESTION
I need to display a transparent .png image on top of a normal picture. I have tried this aproach, but wxPython says
wxPaintDC can't be created outside wxEVT_PAINT handler
and I can't find a workaround. I binded a wx.EVT_PAINT to some function and tried the code there, with no sucess. Here's my code:
...ANSWER
Answered 2021-Oct-08 at 13:53Found the solution. Just needed to use wx.EVT_PAINT in the right way!
QUESTION
I have a wx.Dialog
with a custom validation process that runs after the OK button is pressed. If the validation fails I would like to shake the wx.Dialog
to let users know that something is wrong with the given input.
Is there something like this implemented in wxPython?
...ANSWER
Answered 2021-Sep-25 at 17:07The simplest way, would be activate a wx.Timer
with a short interval that moves the dialog's position, when the processing fails.
Something like this:
QUESTION
While I'm trying to understand how the WXPython library works, I got to my first issue.
The main issue that I'm having is when i run the code my labels are one over the other on the right panel, while running the following code.
...ANSWER
Answered 2021-Sep-16 at 06:41The parent of self.text in your code is self.display. That cannot happen, because self.display is a StaticText, not a container. If you just add the self.text info the sizer of the right panel, then it will work:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install wxPython
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page