tk

Tcl/Tk: Maximize window / determine if window is maximized?

元气小坏坏 提交于 2019-12-11 05:41:52
问题 Can I find out if my toplevel window is maximized, and can I maximize it programmatically? I am using R's tcltk package 8.5 on Windows XP. The reason for the question is: I want to enforce a <Visibility> event by calling first withdraw and then deiconify. However, if the window was maximized before these two function calls, it is not after these calls. Is there an easier way to enforce the event? 回答1: You can discover the whether the window is maximized with wm state $toplevel (look for

Performance impact when hiding text with elide

让人想犯罪 __ 提交于 2019-12-11 05:01:32
问题 I've setup a Text widget with tags that will hide sections of information using elide. It works fine with normal entries but im seeing performance hits if I hide large sections of text with elide. The text files i've noticed this with are ~53,000 lines and the impact is less with smaller files. The program runs fine and im able to scroll and move around in the window without a problem until I hide I section of text. from tkinter import * master = Tk() file = 'file\path' file1 = 'file\path'

How should a scrollable spreadsheet be displayed within Tkinter?

一笑奈何 提交于 2019-12-11 04:13:14
问题 Currently I am using a Treeview. The problem is that I am using quite a large data set. So that the GUI isn't massive, I've limited the size of the Treeview to fit the window and added vertical and horizontal scrollbars. It displays the data exactly how I want, however there are speed issues when scrolling in each direction. Is there a better/faster way to display spreadsheet-like data. 回答1: The below solution is cobbled together but should achieve the desired result: from tkinter import *

Leak in updating label

喜你入骨 提交于 2019-12-11 02:32:38
问题 I'm new to tkinter and have traced a memory leak in a project I'm doing down to a clock in my code. It turns out the memory leak happens when updating a label, the simplest example I've got it down to in code is: import Tkinter as tk class Display: def __init__(self, master): self.master = master self.tick() def tick(self): self.label = tk.Label(self.master, text = 'a') self.label.place(x=0,y=0) self.master.after(50, self.tick) root = tk.Tk() disp = Display(root) If somebody could tell me why

How to undersand the POE-Tk use of destroy?

不羁岁月 提交于 2019-12-11 00:46:03
问题 Here is some test code to illustrate my problem; use Tk; use POE qw( Loop::TkActiveState ); use Tk::Toplevel; POE::Session->create( inline_states => { _start => \&ui_start ,top1 => \&top1 ,top2 => \&top2 # ,kill_top1 => \&kill_top1 ,kill_top1 => sub { $heap->{tl1}->destroy; } ,over => sub { exit } } ); $poe_kernel->run(); exit 0; sub ui_start { my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP]; $heap->{mw} = $poe_main_window; $but1 = $heap->{mw}->Button( -text => 'Exit', -width => 12,

Python 3 - How do I use tkinter progressbar with a bat file?

本小妞迷上赌 提交于 2019-12-10 23:52:32
问题 So far, the bat runs but the progress bar doesn't. How do I connect the two with each other? Here is the image of the output. http://imgur.com/lKbHepS from tkinter import * from tkinter import ttk from subprocess import call def runBat(): call("mp3.bat") root = Tk() photobutton3 = PhotoImage(file="smile.png") button3 = Button(root, image=photobutton3, command=runBat) button3.grid() pbar = ttk.Progressbar(root, orient=HORIZONTAL, length=200, mode='determinate') pbar.grid() root.mainloop() 回答1:

Handle touchscreen gesture in Tkinter

核能气质少年 提交于 2019-12-10 18:43:52
问题 How would I go about installing a handler of touchscreen gestures in Tkinter? I need to something particularly simple: to increase the font size whenever an 'expand' gesture is detected. Is this even possible to do in Tkinter if Tcl/Tk doesn't specifically implement it? I suppose that either the window manager sends the client window some event that I could listen for and handle, or the client must register to the window manager a handler for a specific kind of event, but if it isn't possible

Intercept event when combobox edited

夙愿已清 提交于 2019-12-10 17:40:51
问题 I'm using a ComboBox as part of a larger GUI, written in python/tkinter. When the drop-down selection is changed, the color is updated to indicate to the user that something has changed. However, the combobox also allows the user to type in their own value. I also want the color to change when this happens. The problem is, I don't see anything in the ComboBox documentation indicating how to do this. 回答1: You can use a StringVar as a parameter of the Combobox constructor. This StringVar can be

Why does the Tkinter canvas request 4 extra pixels for the width and height?

痞子三分冷 提交于 2019-12-10 15:02:54
问题 >>> import Tkinter >>> c = Tkinter.Canvas(width=100, height=100) >>> c.winfo_reqwidth() 104 >>> c.winfo_reqheight() 104 The results are the same if I set borderwidth to zero. I can't find the setting or property that explains or controls these 4 extra pixels. 回答1: Got it! c = Tkinter.Canvas(width=100, height=100, highlightthickness=0) >>> c.winfo_reqwidth() 100 The way I debugged the problem may also be useful to others in need: import pprint pprint.pprint(c.configure()) {'background': (

Tk/Tkinter: Detect application lost focus

心已入冬 提交于 2019-12-10 14:59:02
问题 I am making a Tkinter application. In the application, I want to pop up a context menu, which I do using Tk.Menu.post(). I don't know how to make this menu disappear when the application loses focus. I need to do this because the menu stays on top, even when switching to another window, leaving a menu 'artifact'. I put a <FocusOut> event on the menu, which is triggered if the menu has focus and the user moves focus to another application. This works well. What do I do if the main application