tkinter

A Label in a Frame in a window won't stretch, why?

时光毁灭记忆、已成空白 提交于 2021-02-10 16:42:52
问题 I would like to display a window with a single Frame and a Label in the Frame which would stretch to the whole width of the window The following code import Tkinter as tk root = tk.Tk() root.geometry("100x100") # first column of root will stretch root.columnconfigure(0, weight=1) # a frame in root upper_frame = tk.Frame(root) # first column of upper_frame will stretch upper_frame.columnconfigure(0, weight=1) upper_frame.grid(row=0, column=0) # a label in upper_frame, which should stretch

How do I disable keyboard input into an Entry widget, disable resizing of tkinter window and hide the console window?

徘徊边缘 提交于 2021-02-10 16:21:10
问题 I am making a calculator using tkinter and I wish to do the following: Disable keyboard input for the Entry widget so that the user can only input through the buttons. Even after disabling keyboard input for the Entry widget, I wish to be able to change the background and foreground of the widget. I wish to hide the console window because it is totally useless in the use of this calculator. I don't want to let the user resize the root window. How do I disallow the resizing of the root window?

How do I disable keyboard input into an Entry widget, disable resizing of tkinter window and hide the console window?

Deadly 提交于 2021-02-10 16:21:03
问题 I am making a calculator using tkinter and I wish to do the following: Disable keyboard input for the Entry widget so that the user can only input through the buttons. Even after disabling keyboard input for the Entry widget, I wish to be able to change the background and foreground of the widget. I wish to hide the console window because it is totally useless in the use of this calculator. I don't want to let the user resize the root window. How do I disallow the resizing of the root window?

How can I disable horizontal scrolling in a Tkinter listbox? (Python 3)

心已入冬 提交于 2021-02-10 16:11:18
问题 Say in Tkinter you have a listbox of a certain size within a window. Then let's say you add a string to that listbox that is larger than that size. If you highlight this element and drag to the side the listbox will automatically "scroll" itself so that you can see the full element. Is there anyway to disable this short of running a thread that repeatedly attempts to set the scroll to 0? import tkinter root = tkinter.Tk() listbox = tkinter.Listbox(root) listbox.insert("end", "Minimal,

Sample Python Timer program

放肆的年华 提交于 2021-02-10 15:53:42
问题 I'm trying to do a timer function in Tkinter python, in which I want to call one method consecutively in timer events. My program is plain sub class, it doesn't contain root or master since I kept master class separate so I am struggling to write the after function, is it possible to write the after function without root? Because calling tk will display the unwanted tk window , I just want to see the timer event output only in my Python shell, is it possible? class App(): def __init__ (self):

Sample Python Timer program

六月ゝ 毕业季﹏ 提交于 2021-02-10 15:52:15
问题 I'm trying to do a timer function in Tkinter python, in which I want to call one method consecutively in timer events. My program is plain sub class, it doesn't contain root or master since I kept master class separate so I am struggling to write the after function, is it possible to write the after function without root? Because calling tk will display the unwanted tk window , I just want to see the timer event output only in my Python shell, is it possible? class App(): def __init__ (self):

can't pickle _tkinter.tkapp objects error when trying to create multiple instances of the same class

丶灬走出姿态 提交于 2021-02-10 15:17:43
问题 I'm becoming really frustrated because of this problem. I had it before and i fixed it, but it came back again when i changed something in my code. To be precise i'm trying to create multiple instances of a class when i'm pressing a button. I am using python 3.6 with tkinter. When i was first writing my class i was using a rectangle (created by using create_rectangle method) for visual representation. After my class was behaving the way i wanted it to i wanted to use a photo to apear on my

can't pickle _tkinter.tkapp objects error when trying to create multiple instances of the same class

无人久伴 提交于 2021-02-10 15:15:29
问题 I'm becoming really frustrated because of this problem. I had it before and i fixed it, but it came back again when i changed something in my code. To be precise i'm trying to create multiple instances of a class when i'm pressing a button. I am using python 3.6 with tkinter. When i was first writing my class i was using a rectangle (created by using create_rectangle method) for visual representation. After my class was behaving the way i wanted it to i wanted to use a photo to apear on my

how to replace the icon in a Tkinter app

别来无恙 提交于 2021-02-10 15:13:05
问题 I am using Python 3.5.0 on Windows 10 and want to replace this: 回答1: To change the icon you should use iconbitmap or wn_iconbitmap I'm under the impression that the file you wish to change it to must be an ico file. import tkinter as tk root = tk.Tk() root.iconbitmap("myIcon.ico") 回答2: You must not have favicon.ico in the same directory as your code or namely on your folder. Put in the full Pathname. For examples: from tkinter import * root = Tk() root.iconbitmap(r'c:\Python32\DLLs\py.ico')

Tkinter window changes dimensions or resolution when I use pyplot

て烟熏妆下的殇ゞ 提交于 2021-02-10 15:00:32
问题 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