tk

What is correct: widget.rowconfigure or widget.grid_rowconfigure?

試著忘記壹切 提交于 2020-01-03 10:42:31
问题 When using grid geometry manager. Let's say you have: import tkinter as tk from tkinter import ttk root = tk.Tk() root.rowconfigure(0, weight=1) root.columnconfigure(0, weight=1) ttk.Button(root, text="Hello World").grid(sticky=tk.NSEW) root.mainloop() The part where you specify the weight of the row/column can also be coded up as: root.grid_rowconfigure(0, weight=1) root.grid_columnconfigure(0, weight=1) For this example, what is correct method: widget.rowconfigure or widget.grid

Tkinter StringVar error

柔情痞子 提交于 2020-01-02 08:11:43
问题 Hi i get an error with this code that StringVar() is not defined, and its probably a small thing but i am not that experienced with tkinter and would like some help, thanks. Here's my code: import tkinter as tk class Converter1(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.entry = tk.Entry(self) self.variable = StringVar() self.variable.set("Miles to Kilometers") # default dropdown menu value self.menu = tk.OptionMenu(self, variable, "Miles to Kilometers", "Kilometers to Miles") self

Substitute for tkinter.dooneevent

怎甘沉沦 提交于 2019-12-31 05:04:08
问题 I am porting a program (VMD, Visual Molecular Dynamics), which is written in C++ and has both Python and TCL interpreters embedded, to Python 3.x. Most of its UI is hard coded using the TCL/TK framework and OpenGl, so UI refreshs are done manually. When the Python interpreter is running it is possible to dynamically create new windows and even add new menus to the main UI using Tkinter. In this case all TK events are flushed by periodically calling some code in the Python side (see below).

changing colour of ttk.Progressbar elements in the xpnative theme - python

早过忘川 提交于 2019-12-31 03:24:28
问题 I'm using python 2.7 and TK to make a gui which accesses text files and uses data in them to do many things, but the one relevant here is sending a gchat message. Currently, I have everything working, the point I need some help with is when I call my module to send the message, the message is sent perfectly, although I wanted the user to have an indication of the process happening, so I created a ttk.progressbar. but there is a few things I'd like to improve on this: 1) I would like to change

How to make Tkinter columns of equal width when widgets span multiple columns (Python 2.7)

旧街凉风 提交于 2019-12-31 01:54:08
问题 In the following, the buttons labelled 'ONE', 'TWO', and 'THR' do not get evenly spaced out. It seems to me that the root of the problem is that Tk is assuming a default minimum width for any column containing part of a widget that spans multiple columns. However, this behaviour appears to be undocumented, so I am unsure how to accommodate for or adjust it in order to get the columns to be of equal width - including the two columns spanned by the text widget and the single column not spanned

How to get widget object from ttk.Notebook tab?

∥☆過路亽.° 提交于 2019-12-25 18:39:22
问题 I have notebook widget of class ttk.Notebook. In this notebook I'm adding many tabs: notebook.add(child=my_object, text='my tab') How can I get tab object and not tab name? UPDATE 1 So, there is children dictionary. OK that brings next problem. What I really want to do is to take my hands on object of active tab in Notebook. So I have this: notebook.children[notebook.select().split('.')[2]]) but it looks ugly. Unfortunately widget name returned by select() has not exactly same format as

How to set the maximum size of BWidget's ScrolledWindow?

依然范特西╮ 提交于 2019-12-25 06:47:47
问题 I am using BWidget 's ScrolledWindow in a code like this: toplevel .top set w [ScrolledWindow .top.scrolledWindow] set f [ScrollableFrame $w.scrollableFrame -constrainedwidth true] $w setwidget $f set a [$f getframe] # here goes some stuff in $a So I get a window with vertical scrollbar. When increasing the height of .top , after some moment all the content in $a becomes visible and the scrollbar disappears as it is not needed anymore. How can I forbid further increasing the height of .top ?

SED in TCL/TK and any other equivalent command in TCL

人走茶凉 提交于 2019-12-25 03:48:42
问题 I am trying pass value from TK to cshell script using "procedure call" now.... as follow. proc Run {} { global passedvalue ## to see what value it has for passedvalue puts $passedvalue exec sed -i {s/ABC/$passedvalue/g} runme.sh exec /bin/csh -c ./runme.sh >@stdout 2>@stderr } I am changing a line which has value ABC by new passedvalue. "puts" works and prints the value of passedvalue properly. But it does not work for sed and it gives Error : Program undefined variable Please let me know how

Perl/Tk menubar quirks

a 夏天 提交于 2019-12-25 03:36:22
问题 I'm trying to add a menubar with the standard File Open, Save and New options. However, instead of behaving as expected, the subroutine handling the open, save and new actions is launched upon creation of the frame. But, when I actually click on them, it is not. Following is the code I'm using. (Main window contains only the menubar) #!/usr/bin/perl use strict; use warnings; use diagnostics; use Data::Dumper; use Tk 8.0; use Tk::NoteBook; use Tk::MsgBox; my $mw=MainWindow->new; $mw->geometry(

How to draw x axis in a canvas using Tcl/Tk

不打扰是莪最后的温柔 提交于 2019-12-25 02:44:16
问题 I wanted to plot an x-axis with respect to time ,for which i have a list which contains time values. Is it possible to display it in a tk canvas?? 回答1: You can easily plot a graph in a Tk canvas. You've just got to work out what points you really want to plot (i.e., assemble both the X and Y values). Adapted from the code on that page: set width 100 set height 100 pack [canvas .c -width $width -height $height] # Assuming you've got a list of points in $data set count 0 foreach yValue $data {