tkinter

Check if window is in background Tkinter

≡放荡痞女 提交于 2021-02-05 09:20:10
问题 So, I'm trying to make an app on tkinter . I've just started learning how this module works. In my app, I have a root window and a child (top leveled) window, and I set the child to be always on top. When I minimize my root window, the child window also minimizes, because I have defined that condition. My problem is when I select other window. When I do it, the child window still stays on top and I want to know if there is a way to know if my root window is in background, a.k.a.: I'm not

how to get tab_id to set it as active tab

≡放荡痞女 提交于 2021-02-05 08:56:09
问题 I am trying to build a text editor using tkinter. i just wanted to set the focus in newly opened tab.By using a static tab_id i can set this for instant but if I have more than 15 tabs at a time it is difficult to find tab_id . i want tab_id with tab_name or tab_title or any other way Here is my code import tkinter as tk from tkinter import ttk, filedialog import os root = tk.Tk() root.title("Tab Widget") tabControl = ttk.Notebook(root) def open_file(event=None): file1 = filedialog

Python Tkinter Label in Frame

我的未来我决定 提交于 2021-02-05 08:33:48
问题 I want to place a label inside a frame in tkinter, but I can't figure out how to actually get it inside. import tkinter from tkinter import * W=tkinter.Tk() W.geometry("800x850+0+0") W.configure(background="lightblue") FRAME=Frame(W, width=100, height =50).place(x=700,y=0) LABEL=Label(FRAME, text="test").pack() When I run this, it doesn't place the Label inside the frame, but just places it normally on the window. What am I doing wrong? 回答1: In the line FRAME=Frame(W, width=100, height =50)

Python tkinter trace error

让人想犯罪 __ 提交于 2021-02-05 08:25:53
问题 I'm trying to write a GUI for my code. My plan is to use tkinter's StringVar , DoubleVar , etc. to monitor my input in real time. So I found out the DoubleVar.trace('w', callback) function. However, every time I make the change I get an exception: Exception in Tkinter callback Traceback (most recent call last): File "C:\Users\Anaconda2\lib\lib-tk\Tkinter.py", line 1542, in __call__ return self.func(*args) TypeError: 'NoneType' object is not callable I have no idea what's going wrong. I'm

How to return a value of a function given as a command in tkinter

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-05 08:23:29
问题 I've written a very simple code with python tkinter , it contains an input box. I'd like to keep the value inserted by the user to myself, in case I need to use it later. Here's the code: import tkinter as tk root=tk.Tk() root.geometry("600x400") def submit(): name=name_entry.get() return name name_label = tk.Label(root, text = 'Username', font=('calibre', 10, 'bold')) name_entry = tk.Entry(root, font=('calibre',10,'normal')) sub_btn=tk.Button(root,text = 'Submit', command = submit) name

How to return a value of a function given as a command in tkinter

断了今生、忘了曾经 提交于 2021-02-05 08:23:06
问题 I've written a very simple code with python tkinter , it contains an input box. I'd like to keep the value inserted by the user to myself, in case I need to use it later. Here's the code: import tkinter as tk root=tk.Tk() root.geometry("600x400") def submit(): name=name_entry.get() return name name_label = tk.Label(root, text = 'Username', font=('calibre', 10, 'bold')) name_entry = tk.Entry(root, font=('calibre',10,'normal')) sub_btn=tk.Button(root,text = 'Submit', command = submit) name

Separate command for clicking each line in Python Tkinter Text Widget

被刻印的时光 ゝ 提交于 2021-02-05 08:09:36
问题 Background Each one of the items appearing in my text widget represent tasks. I am using a Text widget over a ListBox because Text widget allows different colors for different items. The color of each task is its status. Is it possible to set a separate LC command for each task? I have a split-pane application with tasks on the right (possibly scrollable), and I want clicking on a task to open it up for scrutiny in the pane on the left. Main Question Can I in any way activate separate events

python3 tkinter grid and pack, inline packing syntax & elegance

本小妞迷上赌 提交于 2021-02-05 08:07:03
问题 What's the difference between packing a frame "in line" versus ='ing it to a variable and .pack'ing it on the next line? So I saw how to do grid and pack at the same time (see here), but after playing around with it, I ran into something weird. If you change line 16/17 from: f5 = Frame(mainF, bg = "yellow", height=100, width = 60) f5.pack(side=BOTTOM,fill=NONE) to: f5 = Frame(mainF, bg = "yellow", height=100, width = 60).pack(side=BOTTOM,fill=NONE) At the end of the code where the buttons get

python3 tkinter grid and pack, inline packing syntax & elegance

∥☆過路亽.° 提交于 2021-02-05 08:06:51
问题 What's the difference between packing a frame "in line" versus ='ing it to a variable and .pack'ing it on the next line? So I saw how to do grid and pack at the same time (see here), but after playing around with it, I ran into something weird. If you change line 16/17 from: f5 = Frame(mainF, bg = "yellow", height=100, width = 60) f5.pack(side=BOTTOM,fill=NONE) to: f5 = Frame(mainF, bg = "yellow", height=100, width = 60).pack(side=BOTTOM,fill=NONE) At the end of the code where the buttons get

vertical padding between buttons in a column

倖福魔咒の 提交于 2021-02-05 07:48:27
问题 When I pad the widgets they all just move together on the same frame in 1 big block. I need to be able to separate them and add the padding between each widget on the same frame. This is part of my code I tried: def CreateDisplay(self): self.mainwindow = tk.Tk() self.mainwindow.geometry("800x600") self.mainwindow.wm_title(self.constants.NAME) self.mainwindow.resizable(width=False, height=False) self.frame_main = tk.Frame(master = self.mainwindow) self.frame_title = tk.Frame(master = self