tkinter

Python - Tkinter Label Output?

会有一股神秘感。 提交于 2021-01-29 01:57:31
问题 How would I take my entries from Tkinter, concatenate them, and display them in the Label below (next to 'Input Excepted: ')? I have only been able to display them input in the python console running behind the GUI. Is there a way my InputExcept variable can be shown in the Label widget? from Tkinter import * master = Tk() master.geometry('200x90') master.title('Input Test') def UserName(): usrE1 = usrE.get() usrN2 = usrN.get() InputExcept = usrE1 + " " + usrN2 print InputExcept usrE = Entry

tkinter and pygame do not want to work in one window [duplicate]

只愿长相守 提交于 2021-01-28 21:12:03
问题 This question already has answers here : Unable to install pygame on Python via pip (Windows 10) (6 answers) Closed 8 days ago . I want to create an application and want to use tkinter as GUI and one of game libraries as Pyglet and Pygame. I didn't find any info about embedding pyglet into tkinter but found some code with tkinter and pygame: Embedding a Pygame window into a Tkinter or WxPython frame. I'm using python 3.7 and here is the code that I use: import pygame import tkinter as tk from

ttk.OptionMenu outer border around the menu

旧巷老猫 提交于 2021-01-28 20:01:14
问题 I try to style a tkinter gui, first this gui is not easy to modify. I reach the styling i want for the widgets i use, except for one think. I get lock about this light gray border around the Menu in the ttk.OptionMenu widget. How removing or coloring it ? Python 3x on Windows 10 Here just the relevant parts of the code. Some common styling: self.style = ttk.Style(self) self.style.theme_use("clam") self.font12 = tkFont.Font(family="helvetica", size=12) self.font14 = tkFont.Font(family=

Tkinter, Label/Text in canvas.rectangle [python]

寵の児 提交于 2021-01-28 19:45:16
问题 I need to place a text/label centred in a canvas rectangle in tkinter. First I have a canvas covering the whole screen(800, 600). And then I have a couple of rectangles which I made using the: create_rectangle(...) The first X of the first rectangle is 275 and the second X is 525. The first Y of the first rectangle is 265 and the second Y is 315. menuBtn1 = canvas.create_rectangle(275, 165, 525, 215, fill="#C2B6BF") Now how I can place a text/label in the center of this rectangle? 回答1: You

How to make table out of lists using TreeView Tkinter Python

六月ゝ 毕业季﹏ 提交于 2021-01-28 19:35:16
问题 What I want.. is to how create a table using TreeView Tkinter and data which is to be inserted in the table should from lists. For example: This is the list i have ID = [1,2,3,4,5] Names = ['Tom', 'Rob', 'Tim', 'Jim', 'Kim'] And I want to create a table with headings "ID" and "Names" and I don't want to put each values in the table separately. Well this is a small list but even when I want to create a bigger table. So can anyone tell me how can I insert these list data in table automatically

How can I update Entry without a “submit” button in Tkinter?

混江龙づ霸主 提交于 2021-01-28 19:34:49
问题 So I have Entries which have some values assigned to them from a CFG File. I want to modify the CFG file when the Entry is updated, live, without a submit button; Using <Key> binding will work but will take only the previous value, not the current one, as the last key pressed is not taken into consideration as a value, but as a key-press . For example: class EntryBox: def __init__(self, value, option, section, grid_row, master_e): self.section = section self.option = option self.box = Entry

Python 3 binding not working

主宰稳场 提交于 2021-01-28 18:12:09
问题 Somehow only 2 of my bindings work(left and right mousebutton). I've done quite a few bindings in my previous programmes, but still, I have no idea why this doesn't work. Could somebody help me? class Window: def __init__(self): self.win=Tk() self.can=Canvas(self.win, height=800, width=800, bg="grey90") self.can.grid(row=0, column=0) class Player: def __init__(self, bind1, bind2): win.can.bind(bind1, self.moveleft) win.can.bind(bind2, self.moveright) def moveleft(event, self): print("left")

Execute tkinter button without clicking on it

人盡茶涼 提交于 2021-01-28 18:10:10
问题 I have a Python GUI which makes a simple calculation. Running the main file called gui.py opens up a graphical interface. I would like to open the graphical interface and automatically click on the Kjør beregning button . (it means "Run calculation" in norwegian). Button is defined the following way in gui.py : beregn_btn = tk.Button(av_beregn, text="Kjør beregning", font=bold, command=self._beregn) I'd like to add some code here to invoke calculation, if that is possible: So far without luck

Execute tkinter button without clicking on it

一个人想着一个人 提交于 2021-01-28 18:08:44
问题 I have a Python GUI which makes a simple calculation. Running the main file called gui.py opens up a graphical interface. I would like to open the graphical interface and automatically click on the Kjør beregning button . (it means "Run calculation" in norwegian). Button is defined the following way in gui.py : beregn_btn = tk.Button(av_beregn, text="Kjør beregning", font=bold, command=self._beregn) I'd like to add some code here to invoke calculation, if that is possible: So far without luck

How merge text in a tkinter label with different colors

£可爱£侵袭症+ 提交于 2021-01-28 14:13:25
问题 I'm coding a little stocks ticker displayer program with tkinter label and I need to merge in the same line text in red color and green color. How can I do that? If not, is there any other widget which I can do it with? 回答1: You cannot have multiple colors in a label. If you want multiple colors, use a one-line Text widget, or use a canvas with a text item. Here's a quick and dirty example using a text widget. It doesn't do smooth scrolling, doesn't use any real data, and leaks memory since I