tkinter | Tkinter GUI for cool animations | Animation library
kandi X-RAY | tkinter Summary
kandi X-RAY | tkinter Summary
Tkinter GUI for cool animations.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of tkinter
tkinter Key Features
tkinter Examples and Code Snippets
Community Discussions
Trending Discussions on tkinter
QUESTION
script_a.py
...ANSWER
Answered 2022-Apr-18 at 02:03With many hours of testing, I did have success in running two Tk() loops, but it had potential to be problematic, as "Bryan Oakley" had posted in many threads about.
Ultimately, I decided when I was in need of running something alone, I'd start my GUI with arguments and process it in an entirely new process instead of passing any arguments directly. Seems like a safer option.
QUESTION
I know that menu.tk_popup() can be used to open a context menu at a certain coordinate, but don't know how to open a submenu out of it too, if that makes sense. This is the code I made:
...ANSWER
Answered 2022-Apr-12 at 06:22So the question is, how do I make it so when middle-clicking, it opens the first menu AND then automatically runs the cascade, as if it was clicked?
Considering this answer by Bryan Oakley and the documentation available on the internet, there is no way for making a menu and a submenu visible simultaneously. "That's just not how Tkinter menus are designed to work."
You will have to create a customized menu bar without using the widget tk.Menu
.
When I middle-click, I tried to make it so it displays both the menus (my_menu, my_menu2), but my attempt just displays both but with the first menu overlapping, so the other doesn't show.
They are not overlapping. Even if you add some gap to the x-y values using some integers, still you won't be seeing the second menu.
The reason is that using tk_popup
or post
will make the menu appear on the screen for sure, but then the program's focus gets shifted to the user's mouse and keyboard. So, until the user clicks out of the focus of that menu, the program won't be coming out to execute the next lines of the function (in which you are calling the tk_popup for the submenu.)
Here you can see what I mean:
QUESTION
I have created a GUI app in Python tkinter for analyzing data in my laboratory. There are a number of buttons, figures, and canvas widgets. It would be helpful to take a screenshot of the entire window ('root') using just a single button that saves the filename appropriately. Example using Mac's built-in "screenshot" app here.
Related questions here, here, and here, but none worked successfully. The final link was almost successful, however the image that is saved is my computer's desktop background. My computer is a Mac, MacOS Monterey 12.0.1.
'root' is the tkinter window because
...ANSWER
Answered 2022-Jan-14 at 22:44First, I didn't have an issue with the grab showing my desktop, but it was showing an improperly cropped image.
I have found a hacky solution. The issues appears to be with the resolution. So the dimensions need some scaling.
What I did was get the output from ImageGrab.grab().save(full_file_name)
( no cropping ) and measure the size of the desired image area in pixels. These dimensions will be called x_pixels
and y_pixels
.
Then I measured that same area on the actual window in screen units. I did this by bringing up the mac screenshot tool which shows the dimensions of an area. I then call these dimensions x_screen
and y_screen
. Then I modified your screenshot function as follows.
QUESTION
I made a Fourier Series/Transform Tkinter app, and so far everything works as I want it to, except that I am having issues with the circles misaligning. Here is an image explaining my issue (the green and pink were added after the fact to better explain the issue):
I have narrowed down the problem to the start of the lines, as it seems that they end in the correct place, and the circles are in their correct places. The distance between the correct positions and the position where the lines start seems to grow, but is actually proportional to the speed of the circle rotating, as the circle rotates by larger amounts, thus going faster.
Here is the code:
...ANSWER
Answered 2022-Mar-05 at 20:55The main problem that you are facing is that you receive floating point numbers from your calculations but you can only use integers for pixels. In the following I will show you where you fail and the quickest way to solve the issue.
First your goal is to have connected lines and you calculate the points here:
QUESTION
I have a checkbutton:
...ANSWER
Answered 2022-Mar-04 at 15:23You can bind the left mouse button click event of the label, to a lambda construct that toggles the checkbutton -:
QUESTION
The 3 example files executable are: main.py
, page1.py
and external_class.py
. The main.py file is used to start the main GUI and the page1.py file contains the class in which I import another class from the external_class.py file.
The problem is that the External class of the external_class.py file is unable to execute an element of the Page1 class of the page1.py file. The element is obtained from the combobox present in the Page1 class of the page1.py file, so I don't want to rewrite the code from scratch in the External class of the external_class.py file, but I just want the External class to recognize the select_only_way element.
In the External class of the external_class.py file, I use select_only_way
like this self.cursor.execute ('SELECT a, b FROM other WHERE a = ?', [Select_only_way])
. The problem is right here, in the External class of the external_class.py file.
I get error in the External class of the external_class.py file.
...ANSWER
Answered 2022-Jan-19 at 18:14The basic problem is that you have not created a reference to the attribute.
First of all, care should be taken to prefix all attributes inside a new object (class Page1 __init__) with self.
in front of all attributes.
This makes the value part of the object and
can be called after the initialization.
In your case, the entire class could be passed as an argument to External.
QUESTION
Python 3.9 on Mac running OS 11.6.1. My application involves placing a plot on a frame inside my root window, and I'm struggling to get the plot to take up a larger portion of the window. I thought rcParams
in matplotlib.pyplot
would take care of this, but I must be overlooking something.
Here's what I have so far:
...ANSWER
Answered 2022-Jan-14 at 23:23try something like this:
QUESTION
[Editing this question completely] Thank you , for those who helped in building the Periodic Table successfully . As I completed it , I tried to link it with another of my project E-Search
, which acts like Google and fetches answers , except that it will fetch me the data of the Periodic Table .
But , I got a problem - not with the searching but with the layout . I'm trying to layout the x-scrollbar in my canvas which will display results regarding the search . However , it is not properly done . Can anyone please help ?
Below here is my code :
...ANSWER
Answered 2021-Dec-29 at 20:33I rewrote your code with some better ways to create table. My idea was to pick out the buttons that fell onto a range of type and then loop through those buttons and change its color to those type.
QUESTION
EDIT [resolved]
based on the answer from Thingamabobs below, the approach simply turns out to be making sure the elements you spawn are allocated to correct parents.
It is worthwhile to create a frame just to hold every scrollable element since you can't move widgets around between parents when using pack/place
. So a common parents between all movable
elements will give you the freedom to move them around, again just create a holder frame. See the answer and discussion below for more details.
EDIT2
Bryan's answer below has very good info and an alternate approach using just a canvas. The core concepts still stand the same.
original question begins here
The situationSo based on this answer by Bryan, I used this approach to spawn widgets on a scrollable frame
(which is basically a Canvas
wrapping a frame inside as we know cause Frames don't have scroll attributes).
The widgets in this case are just tk.Button
s which I spawn in a loop using lambda to preserve state. That aspect is completely fine.
Now everything works fine except when I spawn more elements (again just buttons), they seem to be cut off. and I can't seem to scroll down to see the remaining ones. I am only able to scroll upwards only to see empty space.
please see the video below to see what I mean (excuse my horrible color choices, this is for a quick demo)
In the video, there are more elements below template47
but I can not scroll to them. I can scroll upwards but it's just lonely up there. All the names are actually buttons with zero bd
and HLthickness
.
To begin, my first instinct was to attach a ttk.scrollbar
to the canvas+frame
, which I did but observed the exact same behavior.
Then I tried to see if i could use .moveTo('1.0')
to scroll down to last entry and then since upward scrolling works already, shouldn't have an issue. But this didn't do anything either. Still the elements were cut off, and it obviously messed up upward scrolling too.
I don't think I can use pack/grid
geoManagers since as the answer by bryan i linked to above suggests, using place
with its in_
arg is the preferred way. If it is possible otherwise, let me know though.
as depicted in the answer linked above, I also have two frames, and I'm using the on_click callback function to switch parents (a lot like in example code in answer). Turned out place was the best bet to achieve this. and it is, all of that aspect is working well. It's just the scroll thingy which doesn't work.
some code (dare i say MCVE)how i bind to mousewheel
...ANSWER
Answered 2021-Dec-27 at 14:37The main issue is that you are using place
and with place you will be the allmighty over the widget, means there will be no requested size to the master or any other magic tkinter provides in the background. So I do recommand to use another geometry manager that does that magic for you like pack. Also note that I set the anchor to nw
.
In addition it appears that you can only use the optional argument in_
in a common master. So the key of that concept is to have an holder frame that is used as master parameter and use the in_
for children that are able to hold widgets.
QUESTION
Beginner programmer here currently trying to learn Tkinter for a school assignment. I have a GUI class that stores the Tkinter labels etc, the labels are innitiated like this:
...ANSWER
Answered 2021-Dec-27 at 17:25The issue is self.root.update()
. Remove this line and you'll be fine.
When should I use root.update() in tkInter for python.
This is a tricky issue. Your problem come from the bind of the configure event. Bind to the root window, it is applied to all sub-widgets of the window, which cause the bug (I don't know why yet).
This will solve your issue (line 202):
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
Install tkinter
You can use tkinter like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
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