tk

Tcl/Tk: Frames misbehave when resizing.

偶尔善良 提交于 2019-12-11 09:37:44
问题 I am relatively new to Tcl/Tk but have been working with it fairly successfully, non-stop for the last several weeks. For the most part it seems fairly straightforward. However, I've hit a snag recently which is probably simple but I can't seem to figure it out. I have reduced my fairly complicated code to a few lines which demonstrate the problem. My simple example produces two labelframes with a simple label widget in each. When I resize (i.e., expand) the main window, I want the “left”

Tk text widget index expressions and Unicode

≯℡__Kan透↙ 提交于 2019-12-11 07:59:44
问题 (this question is based on that) Let us consider the following code: package require Tk 8.6 pack [text .t] .t insert end "abcdefgh\nабвгґдеє\n一伊依医咿噫欹泆" puts "[.t index 1.4+1l] [.t index 1.4+2l]" puts "[.t index 3.4-1l] [.t index 3.4-2l]" exit 0 Output: 2.2 3.2 2.6 1.8 I would rather expect +1l and -1l to preserve the column if the line is long enough, that is, to print 2.4 3.4 and 2.4 1.4 . It looks like the result depends on the number of bytes needed to encode each character. Should it be

Mainloop and Text with threads

一曲冷凌霜 提交于 2019-12-11 07:59:42
问题 I have threads that use some class's functions , and those functions print alot of stuff , that i want to display on a Text() widget . So i tried making the window in the class as a class variable and the command : mainloop() seems to stop everything from continuing .... Is there any solution for that ? The general idea i want to do : (converting the console to GUI..) from tkinter import * root = Tk() textbox = Text(root) textbox.pack() def redirector(inputStr): textbox.insert(INSERT,

Default Image sizes in ttk.Label

北城余情 提交于 2019-12-11 07:54:11
问题 Currently I'm using this snippet of code which seems pretty easy: label = ttk.Label(mainframe) image1 = PhotoImage(file='my_image.gif') label['image'] = image1 label.grid(column=1, row=0) However, if I edit the size of my_image.gif in photoshop, then run it again, the image gets stretched to the same size, and this seems to continue no matter how small I make the base image. This seems to suggest to me that the PhotoImage or something above it enforces a default size or specific minimum size.

How can I set a tkinter app icon with a URL?

依然范特西╮ 提交于 2019-12-11 07:18:54
问题 If I have: from Tkinter import * app = Tk() ... app.mainloop() Would I use app.iconbitmap(...) ? And if so, how would I go about using this as the file, and should I import urllib ? 回答1: You can use this too replace the Tkinter default icon. import base64, PIL, urllib, Tkinter from Tkinter import * from PIL import ImageTk from urllib import * root = Tk() raw_data = urllib.urlopen("http://dl.dropboxusercontent.com/s/qtlincxkbbiz1qv/stat.gif").read() b64_data = base64.encodestring(raw_data)

Python 3.3 TKinter image doesn't exist

北城余情 提交于 2019-12-11 07:16:17
问题 I am trying to open an image with ImageTk.PhotoImage from PIL but I keep hitting the same error. I have the image and can see that it is there when it downloads it, it opens it, but then I get the error that it is not there. Here is the error Exception in Tkinter callback Traceback (most recent call last): File "C:\Python33\lib\tkinter\__init__.py", line 1475, in __call__ return self.func(*args) File "S:/Projects/xmlParser.py", line 128, in updateSelected self.threadLabelImage.config(text =

TCL\TK Resize window : bind

旧城冷巷雨未停 提交于 2019-12-11 06:35:30
问题 I have problem when I resize my window ,I don't understand why, when I move my window . my another window created with .c bind cir <1> [list window %x %y] do not follow my window . I believe that I've to use <Configure> as option, but I don't know how to do Thanks for your help My code below : proc window {crx cry} { set w1 .win catch {destroy $w1} toplevel $w1 wm minsize $w1 300 100 wm maxsize $w1 300 100 label $w1.l -text "$crx $cry" pack $w1.l } wm state . zoomed canvas .c -bg ivory .c

How to implement tk scrollbar for multiple listboxes (TCL)?

旧巷老猫 提交于 2019-12-11 06:31:00
问题 I tried all sort of options but no success in implement simple scrollbar for two or more listboxes. Following is my code giving error while scrolling. I hope you guys are helping me... scrollbar .scroll -orient v pack .scroll -side left -fill y listbox .lis1 pack .lis1 -side left listbox .lis2 pack .lis2 -side left for {set x 0} {$x < 100} {incr x} { .lis1 insert end $x .lis2 insert end $x } .lis1 configure -yscrollcommand [list .scroll set] .lis2 configure -yscrollcommand [list .scroll set]

Structure of XML file is preventing me from reading it with python

别说谁变了你拦得住时间么 提交于 2019-12-11 06:18:29
问题 I'm setting up a python script that will ask for a list of input xml files that all have the same format and read out a specific line from each xml file. Everything works as I want it to, however I am getting an error when reading from the xml file due to the content of the xml file itself. I have got the script to work by editing the xml file but this is not a solution for me as I need this script to run thousands of files here is the code I'm using: import os import tkinter as tk from

matplotlib figure does not continue program flow after close event triggered inside tk app

别等时光非礼了梦想. 提交于 2019-12-11 05:46:38
问题 I've come across a really annoying difference between how windows and mac handles a python tk window and matplotlib figure close_event. My problem is thus, I am trying to load a matplotlib figure from a tk button event. I want the figure to show, and block the tk UI program flow while the plot is active, and capturing user events until the plot is closed. After the plot is closed the tk app should continue. Minimal example app showing issue. from Tkinter import * from matplotlib import pyplot