tkinter

Why is the menu not appearing in the window?

社会主义新天地 提交于 2021-01-29 18:15:12
问题 I'm trying to add a menu into the UI but it doesn't show up. I copied everything directly from effbot.org/tkinterbook/menu.htm but it still isn't working. I'm using Python 3 and macOS 10 if that's relevant. from tkinter import * master = Tk() master.geometry('300x300') master.title('Table') def hello(): print("hello") menubar = Menu(master) menubar.add_command(label = "Hello!", command = hello) menubar.add_command(label = "Quit!", command = master.quit) master.config(menu=menubar) master

How to save information from the program then use it to show in program again (simple programming)

和自甴很熟 提交于 2021-01-29 17:35:57
问题 I have a user-interface, I made. It has Entry form and Treeview section. When I entry information, it show on the treeview (table with 4 column). But when I close the built gui, Those information disappear then when I build again no information show in treeview. I don't want to send information to data server or any clouds, I need save it in my local drive or local folder that this program locate. # from tkinter import * from tkinter import ttk import webbrowser as web def addit() : web =

Pass values to python script with Tkinter

老子叫甜甜 提交于 2021-01-29 17:11:31
问题 So I've written a python script that uses the PIL library to format a png passed to it. I want to make the script more user friendly and after looking around I saw the Tkinter library which seemed perfect. Basically the script has five variables that I need to pass to it for it to run. I'm currently using the raw_input() function to asking the user for the following variables: path_to_png title subtitle source sample_size Once received the script runs and exports the formatted png. I've used

how to update curve plot in animation ( tkinter) of python

穿精又带淫゛_ 提交于 2021-01-29 17:06:37
问题 from the following code, I could update the line by clicking the "replot" button. I have to use both set_data() and also plot a new plot, otherwise the old plot is still here. However, I want the program automatically to update the curve inside of animate(), I use a 5 secs control to trigger replot() function, but it fails. if I do not use blit=True, just use blit=False, then everything is fine. Then my question is how to update the curve in animation triggered by condition, and also need to

How to create zigzag movements in Python?

╄→гoц情女王★ 提交于 2021-01-29 16:12:29
问题 from tkinter import * def move(): global x1, y1, dx, dy, flag, n, z x1, y1 = x1 + dx, y1 + dy if x1 > 360: x1, dx, dy = 360, -15, 5 can1.itemconfig(oval1, fill = "purple") if x1 < 10: x1, dx, dy = 10, 15, 5 can1.itemconfig(oval1, fill = "red") if y1 == 360: x1, dx, dy = 360, -15, -5 can1.itemconfig(oval1, fill = "green") can1.coords(oval1, x1, y1, x1 + 30, y1 + 30) if flag > 0: abl1.after(50, move) def stop(): global flag flag = 0 def start(): global flag if flag == 0: flag = 1 move() ### x1,

text doesn't contain any characters tagged with “sel” tkinter

感情迁移 提交于 2021-01-29 15:43:15
问题 I recently read on of the answers written by respected Bryan Oakley(Tkinter adding line number to text widget) where he showed a sample code about solving the problem. When I tried working on that code & it worked correctly till I copy or paste something, i.e. I press Ctrl+C or Ctrl+V . It closed the tkinter window with the following error: _tkinter.TclError: text doesn't contain any characters tagged with "sel" Here is the code: import tkinter as tk class TextLineNumbers(tk.Canvas): def _

Error when opening different windows in turtle using tkinter

帅比萌擦擦* 提交于 2021-01-29 15:17:40
问题 I have a problem using turtle with tkinter in Python 3.8. Still new to programming so thanks in advance! I have a tkinter window where you can chose to play either level one or two, every time you start the program either level will work but once you have finished the level and try another level, including the same level I get an error. error message: "Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\Kev\AppData\Local\Programs\Python\Python38\lib\tkinter\__init_

summarise code in python with many if-clauses

做~自己de王妃 提交于 2021-01-29 15:11:21
问题 I am currently using a lot of code for this. Is there a way to summarise the code? Thanks a lot! I would like to summarise the If conditions. ''' if self.calculations["A1"].get() == 0 and event_measure == "A1": self.Menu_blade_exchange["A1"].grid(row =2, column = 1, padx=3, pady=1, sticky = "W") self.Menu_rubbing_marks["A1"].grid(row =2, column = 2, padx=3, pady=1, sticky = "W") if self.calculations["A1"].get() == 1 and event_measure == "A1": self.Menu_blade_exchange["A1"].grid_forget() self

Copy items from treeview tkinter

情到浓时终转凉″ 提交于 2021-01-29 15:06:03
问题 I have a tree view in one of my tkinter app and i wanted to know if it really is possible to actually, just copy a selected field on right-clicking by the user. If not , is there any other widget tht allows the user to copy a selected field shown in GUI window. Code: log = Toplevel(root) log.title('View all Visitors') log.focus_force() # setup treeview columns = (('ID', 80), ('S_ID', 80), ('S_NAME', 300), ('Title of the book', 500), ('Accession no. of book', 80), ('Date Taken', 100), ('Due

how to use destroy in these cases

不羁的心 提交于 2021-01-29 15:06:01
问题 ran into another problem when handling modules. I can't get "destroy" to work. I want to open with a button and close with another button the toplevel window. Here is a little code to apply destroy # module uno.py import tkinter as tk class PRUEBA: def __init__(*args): ventana_principal = tk.Tk() ventana_principal.geometry ("600x600") ventana_principal.config (bg="blue") ventana_principal.title ("PANTALLA PRINCIPAL") def importar(): from dos import toplevel top = toplevel(ventana_principal)