tkinter

Tkinter, python 3.8.1, win10Pro, How can I change a label image?

自闭症网瘾萝莉.ら 提交于 2021-01-29 14:55:41
问题 This is my VERY first post so forgive my newness. I'm trying to make a GUI of a dice rolling game (2 x six-sided). Logic of the random rolls is working fine to console. Also in console I see that die number is mapping to correct image file, but I'm having trouble changing tkinter label images to the new corresponding images on every roll beyond the initial startup roll. On startup, it displays both die images correctly, but when I click "roll" button, both images from first roll just

Using exec to define and get the value from variables raises NameError

自闭症网瘾萝莉.ら 提交于 2021-01-29 14:53:02
问题 Right now I'm working on a project that will ask for a runner's name, 1 mile, 2 mile, and 5 miles times and generate data based off that. The requirement is to have enough entries for 7 runners but I thought I'd add the ability to add any number of runners by using exec() . However, when trying to read data from the variables defined within them, I get a NameError: name 'entry2' is not defined but not for entry0 and entry1 , so I was wondering if anyone could help me out on these. In case it

Get coordinates of “treasure” (turtles) in Maze Game that uses Python tkinter and turtle

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 14:50:44
问题 I am using Python 3 to make a maze using tkinter and turtle graphics. Most of the code works, except I cannot figure out how to "destroy" the "gold" in the game. Specifically, calling player.collision() , it says Question object has no attribute xcor even though I got this from a tutorial about a turtle Python maze game. I figured it would work the same as it did in that context, but with tkinter, everything seems to change. The problem occurs under player.collision() and the while loop at

Is there a way to read the contents of a exe file and write it into a label in Tkinter Python?

非 Y 不嫁゛ 提交于 2021-01-29 14:29:33
问题 Iv'e been trying to develop a wrapper GUI for a exe/cmd file, i cant seem to figure out how to read from this file and put the contents into a label in Tkinter and how to write directly to the exe/cmd file through an entry using tkinter. The file also has to be running in the background, something i dont know how to do at all. Iv'e tried to reverse engineer the software but there has to be an easier way. The reason i'm addressing the file as a exe/cmd file is because it is an application file

Display toplevel tk at the begining of a function

风格不统一 提交于 2021-01-29 14:15:42
问题 I have an application where I want to display a progress bar during calcul. So, there is a button on my app to run a function and also display the progress bar, but the child window only appears at the end of the calcul. To reproduce this you can try the code below : import tkinter as tk from tkinter import ttk as ttk class MainApplication: def __init__(self, master): self.master = master self.button_start = tk.Button( self.master, text='Begin', command=self.upload_button) self.button_start

tkinter application waiting for “ctrl” key to be pressed at times

白昼怎懂夜的黑 提交于 2021-01-29 13:32:52
问题 I have a tkinter code . I am using python3 in Ubuntu 18.04 . When I repeatedly run the code the application waiting for "ctrl" key to be pressed .This happens at times say two or three times in 50 runs import tkinter as tk class Demo1: def __init__(self, master): self.master = master self.frame = tk.Frame(self.master) self.button1 = tk.Button(self.frame, text = 'New Window', width = 25, command = self.new_window) self.button1.pack() self.frame.pack() def new_window(self): self.newWindow = tk

Tkinter ttk: background/foregound color will not work on my computer

我只是一个虾纸丫 提交于 2021-01-29 13:10:46
问题 If I run this code via IDLE or a virtual environment in pycharm on both windows 10 and 7: import tkinter as tk from tkinter import ttk x = tk.Tk() y = ttk.Treeview(x) y.insert('',0,values=['red', 'blue'], tags= ('even',)) y['columns'] = ('color1','color2') for item in y['columns']: y.heading(item, text=item) y.tag_configure('even',foreground='yellow',font=('',25)) y.pack() x.mainloop() It changes the font but not the background color. This code does work when run from https://repl.it

Python Tkinter sleep/after not working as expected

你离开我真会死。 提交于 2021-01-29 13:00:51
问题 So what I want to do is that there will be a function from script B which will be called inside the script A. So that function will be displaying some output on the console via print, but what I want is that the output should also be displayed on a widget, and the script A is the one where all my GUI operations happen. So what I did was that I passed a function X as a argument to the function Y in script B, thus, when that output was printed in the function Y, I simply referenced that into a

How to cancel or pause a urllib request in python

南楼画角 提交于 2021-01-29 12:58:57
问题 So I have this program which requests a file from the web and the user can download it. I am using urllib.request and tkinter for my program. The problem is that when the user hits the 'Download' button there is no pause or cancel until the file gets downloaded and the program freezes too. I really want to create a pause or a cancel button, but I do not know how and I want to eliminate the freezing of the program. Should I use another library like 'requests'? Or should I try threading? Can

Keeping Up With Camera Frame Rate in Tkinter GUI

痞子三分冷 提交于 2021-01-29 12:53:21
问题 My goal is to display a real time feed from a USB camera in a Tkinter Window. My problem is that I can't seem to update the GUI fast enough to keep up with the frame rate of the camera. I'm interfacing with the camera using the uvclite python wrapper around the libuvc C library. uvclite is a lightweight ctypes wrapper around the underlying C library, so I don't think that piece is my bottleneck. Here is my code: import tkinter as tk from PIL import ImageTk, Image import uvclite import io