tkinter

Tkinter window changes dimensions or resolution when I use pyplot

淺唱寂寞╮ 提交于 2021-02-10 14:59:37
问题 First time posting, but have found these forums incredibly helpful with my python learning! I have a problem when I call plt.plot as it's resizing my tkinter window. I've tried this in python 2.7 and 3.5 both seem to have the issue. Below is just some sample code to re-create the problem. You don't even need to show the graph for this problem to be re-created as soon as you plot the data it resizes. Before After from tkinter import * import matplotlib.pyplot as plt x = [1,2,3,4,5] master = Tk

Tkinter window changes dimensions or resolution when I use pyplot

时间秒杀一切 提交于 2021-02-10 14:58:37
问题 First time posting, but have found these forums incredibly helpful with my python learning! I have a problem when I call plt.plot as it's resizing my tkinter window. I've tried this in python 2.7 and 3.5 both seem to have the issue. Below is just some sample code to re-create the problem. You don't even need to show the graph for this problem to be re-created as soon as you plot the data it resizes. Before After from tkinter import * import matplotlib.pyplot as plt x = [1,2,3,4,5] master = Tk

Getters in python, tkinter

送分小仙女□ 提交于 2021-02-10 14:53:49
问题 I need access to information from my class "makeEntry" precisely textvariables. I tried make get function but i read that in python it's not necessary. def temp(): print(e_full_name.get_text()) class makeEnetry: def __init__(self, i_parent, i_width, i_row, i_column, i_text): test.set(i_text) test = StringVar() entry = Entry(master = i_parent, width = i_width, textvariable = test) entry.grid(row = i_row, column = i_column, padx = 5, pady =5 ) def get_text(self): return self.test.get() I tried

cx_freeze Tkinter 'Module not Found'

て烟熏妆下的殇ゞ 提交于 2021-02-10 14:21:01
问题 I am trying to create an executable from my python scripts. I am using Windows 7, cx_freeze 5.0.2 and Python 3.6. I know Tkinter isn't included in the normal libraries and that you need to add something similar to the following 2 lines: os.environ['TCL_LIBRARY'] = "C:\\Program Files\\Python35\\tcl\\tcl8.6" os.environ['TK_LIBRARY'] = "C:\\Program Files\\Python35\\tcl\\tk8.6" Except of course for 3.6 and in my location, however I can't find their directory in Anaconda 3.6 I create the following

Detect if user has clicked the 'maximized' button

梦想与她 提交于 2021-02-10 14:18:38
问题 I would like to detect if user has clicked the 'maximize' button: In tkInter of course, but I don't know how. I have tried searching through StackOverflow, The Web & tkInter documents(mostly effbot's tkinterbook), but have not found anything related to what I am trying to get. 回答1: There is a good way to does it using .bind() , so let's get started! As we know, we can maximize the window using the command .state('zoomed') . root.state('zoomed') And we can get whatever window event by .bind("

Detect if user has clicked the 'maximized' button

≯℡__Kan透↙ 提交于 2021-02-10 14:17:09
问题 I would like to detect if user has clicked the 'maximize' button: In tkInter of course, but I don't know how. I have tried searching through StackOverflow, The Web & tkInter documents(mostly effbot's tkinterbook), but have not found anything related to what I am trying to get. 回答1: There is a good way to does it using .bind() , so let's get started! As we know, we can maximize the window using the command .state('zoomed') . root.state('zoomed') And we can get whatever window event by .bind("

Is there a way to deiconify root window with keyboard binding?

冷暖自知 提交于 2021-02-10 14:14:37
问题 I'm trying to find a way to deiconify the root window after it's been icononfied. Is this possible? from tkinter import * root = Tk() value = True def callback(_): global value if value: root.iconify() root.focus() value = False else: root.deiconify() value = True root.bind('1', callback) root.mainloop() 回答1: As @Novel mentioned, we must use another module to always listen for keypress event. import tkinter import keyboard root = tkinter.Tk() def callback(): if root.state() == "normal": root

tkinter optionmenu first option vanishes

谁说胖子不能爱 提交于 2021-02-10 14:14:31
问题 A ttk optionmenu widget starts out with all of its values in the dropdown. Upon selecting any value, the first value in the list vanishes, never to reappear... Does anyone know why? Is this a feature of the widget's design? Try it with the following: import tkinter.ttk as ttk import tkinter as tk a = tk.Tk() options = ['1', '2', '3'] value = tk.StringVar() masterframe = ttk.Frame() masterframe.pack() dropdown = ttk.OptionMenu(masterframe, value, *options) dropdown.pack() a.mainloop() Note -

How can I use “sleep” properly?

主宰稳场 提交于 2021-02-10 14:14:22
问题 So, I know about the sleep function, but it doesn't work how I expected it to work. If I do something like this: from time import sleep print('Something') sleep (10) print('Something') It works how (I think) it should (it prints one thing, waits and then prints the other one). But in my code it doesn't work like that. This is the whole code: from tkinter import * from time import sleep # Fenster window = Tk() window.title('Test') c = Canvas(window, height=450, width=800) c.pack() #

Is there a way to deiconify root window with keyboard binding?

≯℡__Kan透↙ 提交于 2021-02-10 14:11:54
问题 I'm trying to find a way to deiconify the root window after it's been icononfied. Is this possible? from tkinter import * root = Tk() value = True def callback(_): global value if value: root.iconify() root.focus() value = False else: root.deiconify() value = True root.bind('1', callback) root.mainloop() 回答1: As @Novel mentioned, we must use another module to always listen for keypress event. import tkinter import keyboard root = tkinter.Tk() def callback(): if root.state() == "normal": root