tkinter

tkinter entry widget not updating

ぃ、小莉子 提交于 2021-01-29 06:31:41
问题 I've searched everywhere on the web but unfortunately no where did I find an answer to this question: after setting a tkinter Entry() widget's textvariable to a textvariable. the text variable does not update after I have typed text into the entry. code below: def saveFileName(self): if(self.save_file_name != ""): self.window.destroy() self.name_not_set = False print("saving...") else: print("notsaving...entry empty") pass def cancel(self): self.name_not_set = False self.exit = True self

Get input in Python tkinter Entry when Button pressed

守給你的承諾、 提交于 2021-01-29 06:21:11
问题 I am trying to make a 'guess the number' game with Pyhon tkinter but so far I have not been able to retrieve the input from the user. How can I get the input in entry when b1 is pressed? I also want to display a lower or higher message as a clue to the player but I am not sure if what I have is right: import time import random import decimal import tkinter as tk root = tk.Tk() randomnum = float(decimal.Decimal(random.randrange(100,10000))/100) guess = 0 def get(entry): guess = entry.get()

tkinter canvas create_text size (python3)

谁说胖子不能爱 提交于 2021-01-29 06:20:59
问题 I understand that it is possible to get the size of text on a canvas: t = canvas.create_text(x, y, text='Hello StackOverflow') print(canvas.bbox(t)) but I want to decide where to draw the text based on its size, so I need to know the size before the text is drawn. How to do that? 回答1: A possible solution is tk.font.Font(size=9, family='Helvetica').measure('HelloStackoverflow') 回答2: Use that line of code. canvas.create_text(245,100, fill = 'red', font = "Times 20 italic bold", text = "Hello

How to get all row information from Treeview widget in Tkinter

依然范特西╮ 提交于 2021-01-29 06:14:17
问题 I want to write a command for a button that will take all of the information from ALL of the rows (except the title row) in my treeview widget and then later paste it onto a label or preferably a listbox. I don't know how to reference the rows of this widget to pass the info from them especially since my widget can have any number of rows depending on the invoice for that customer. Any help is greatly appreciated. import datetime as dt import sqlite3 from tkinter import * from tkinter import

pygame.error: Not an Ogg Vorbis audio stream

久未见 提交于 2021-01-29 05:26:13
问题 When I try to play a sound which is in .ogg format , I get an error: Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\default\AppData\Local\Programs\Python\Python39\lib\tkinter\__init__.py", line 1884, in __call__ return self.func(*args) File "C:\Users\default\PycharmProjects\pythonProject1\main.py", line 17, in read pygame.mixer.music.load(outfile) pygame.error: Not an Ogg Vorbis audio stream Here's the code: from tkinter import * import pyttsx3 import pygame

save syntax with loop in python possible?

烈酒焚心 提交于 2021-01-29 05:25:23
问题 I would like to create a lot of widgets in tkinter. I am currently using a lot of code for this. Is there a way to summarise the code? However, I would still like to be able to capture the value of each widgets. The numbering goes up to 200... Thanks a lot! ''' self.A1_access_measure_calculation = tk.IntVar() self.A1_access_measure = tk.Checkbutton(self.A_Frame_measure, text="A1", variable=self.A1_access_measure_calculation) self.A1_access_measure.grid(row =2, column =0, sticky = "W",padx=25,

Ongoing event in tkinter

痴心易碎 提交于 2021-01-29 05:20:58
问题 Using tkinter, can I bind an ongoing event to activate while the mainloop still goes off? Means it executes the same command over and over until the program is closed 回答1: you can use root.after to run a function repeatedly like so: def repeat_task(): # do stuff root.after(10, repeat_task) this will constantly do something, and then run itself. the delay time shouldn't be 0 because it may not let tkinter's event loop process other events and will freeze. it will go until the window is closed.

Tkinter: How to dynamically insert items to another listbox?

做~自己de王妃 提交于 2021-01-29 04:55:38
问题 Newbie here. I am struggling with Tkinter a bit. I have much more complex program but I created this little script to show you what I'm trying to achieve. I have two listboxes, first one contains some items. When I select one item from first listbox, I want certain thing to be inserted into second listbox. I know that this has to be done via some loop or sth because if you run this script, second listbox has item 4480104160onselect instead of index integer of item in first listbox. I am

tkinter label's image in fixed position

限于喜欢 提交于 2021-01-29 04:47:36
问题 I'm using self.exampleLabel = tk.Label(self,image=self.exampleImage, text="test",compound="left") to create a list of labels and what I got now is: I was wondering is there a way that can enable me to align the star except for put them in another column of labels? Thanks! 回答1: You can make it so that all of the images align to the far left or right, but the label has no concept of columns. You can make it appear like there are two columns if all of the images you use have the same dimensions,

How correctly to set treeview row foreground and background colors

梦想与她 提交于 2021-01-29 04:45:05
问题 I'm having a problem setting the foreground and background colors for ttk.Treeview. I have tried using tag_configure but that doesn't seem to work either. I have some mockup code (below) that I'm using to figure this out. It's possible to change the header colors but not the rows, not sure what I'm doing wrong. from tkinter import * from tkinter.ttk import Treeview, Style class App(Frame): def __init__(self, parent): super().__init__() self.container = Frame.__init__(self, parent) self.tree()