tkinter

Python: Scroll a ScrolledText automatically to the end if the user is not scrolling manually

孤者浪人 提交于 2021-01-28 06:20:45
问题 I made my ScrolledText scroll automatically to the end, based on this answer. Now I'd like to scroll automatically only if the user is not scrolling manually . I was looking for something like this: self.text.offsetBottom (see my comment in the code below) , but couldn't find it yet. Any ideas? Thanks! import time from Tkinter import * import ScrolledText class Example(Frame): def __init__(self, *args, **kwargs): Frame.__init__(self, *args, **kwargs) self.text = ScrolledText.ScrolledText(self

How to insert a scrollbar to a menu?

女生的网名这么多〃 提交于 2021-01-28 06:04:59
问题 I want to add another widget, in this case a scale widget, to a menu widget in tkinter. Right now the only solutions I see are creating a new command and open a new window with the scale widget or creating the scale widget elsewhere. Both don't seem too appealing to me. Any ideas how to archive this are welcome :) 回答1: You cant add a scrollbar to it, but I have coded something similar to this. Its a hacky way and maybe its hard to understand but I can try to explain. Note as Bryan mentioned

How to insert a scrollbar to a menu?

限于喜欢 提交于 2021-01-28 05:56:16
问题 I want to add another widget, in this case a scale widget, to a menu widget in tkinter. Right now the only solutions I see are creating a new command and open a new window with the scale widget or creating the scale widget elsewhere. Both don't seem too appealing to me. Any ideas how to archive this are welcome :) 回答1: You cant add a scrollbar to it, but I have coded something similar to this. Its a hacky way and maybe its hard to understand but I can try to explain. Note as Bryan mentioned

How can I get TK buttons, generated by a for loop, to pass input to their command? (Python)

岁酱吖の 提交于 2021-01-28 05:36:40
问题 I have a program which dynamically generates a GUI. I don't know how many buttons I will have, if any at all. The specific problem is something like this: for varname in self.filetextboxes: if self.varDict[varname]=='': self.varDict[varname] = (StringVar(),) self.varDict[varname][0].set('') fileButton = Button(self, text=" ", command = lambda:self.varDict[varname][0].set(tkFileDialog.askopenfilename()), image=self.filephoto) ftb = Entry(self, textvariable = self.varDict[varname][0],width=40

Seach textbox for a word and move cursor to next match in the textbox?

不问归期 提交于 2021-01-28 05:34:43
问题 I currently have a widget that will search my main textBox and highlight the words that match my search. The problem I am running into is finding a way to move the cursor to the first match found and then subsequently moving the cursor to the next match found the next time I hit enter. I have 2 ways I can search a word in my textbox. One way is to look for every match and change the font,color,size of the word being searched so it stands out from the rest of the text. Here is the function I

Set the same width to an entry and text tkinter label

会有一股神秘感。 提交于 2021-01-28 05:03:59
问题 I would like to put an entry and a text label one under the other and with the same width. Here is my code : from tkinter import * root = Tk() title = StringVar() title_entry = Entry(root, textvariable=title, width=30) title_entry.pack() content_text = Text(root, width=30) content_text.pack() root.mainloop() But my 2 widgets don't have the same width. Any idea to solve it ? 回答1: The widgets are different sizes probably because they have different default fonts. If they have the same fonts and

What is the data format read by the function cv2.imread? Working with tkinter and python

对着背影说爱祢 提交于 2021-01-28 05:02:01
问题 Good day, I am quite new to Python programming and I was tasked to do my own GUI with image inside my GUI. I have been doing some good progress but i was stuck when I want to insert an image into my GUI from my webcam. However, I did manage to get an image from the webcam but it has to be a different window with the GUI window. In my GUI codes, it includes a simple code like this: (I use range i<25 because my webcam needs warming up) for i in range (25): _ , frame = cap.read() frame = cv2

Textbox not expanding with containing frame - TKinter

自作多情 提交于 2021-01-28 05:00:42
问题 I'm building an application that provides viewports for an internal data file. The files are somewhat complex, so I've created three sub-windows that handle different aspects of the file. The upper left provides an outline of the different sections, the upper right provides a series of text widgets containing errors found in the data file, and the lower provides a view of the datafile itself. To facilitate all of this, I wrote a small class that serves as a frame for each of these sections

after() vs update() in python

余生长醉 提交于 2021-01-28 04:44:55
问题 i am new to python and started working with tkinter as canvas. up to now i used .update() to update my canvas. but there is also a .after() method. could anyone explain me this function (with an example please :) ) and is there a difference between: root.after(integer,call_me) and while(True): time.sleep(integer) root.update() call_me i have searched already and couldn't find a good explanation (and my .after examples wont work neither :( ). 回答1: update() yields to the event loop ( mainloop )

cx_freeze error with tkinter library treectrl converting to exe setup

无人久伴 提交于 2021-01-28 04:23:09
问题 I am using python version 3.7 , I used this external library named treectrl and it works perfectly fine when I run my .py file but when I converted into exe file using cx_freeze it is giving me error NomodulleFound named tkinter. I have tried other small programs which does not use this library and I converted them in to exe file they work perfectly fine. So the idea which I got is that there is problem with this library. So I can't figure out what part this. I provided all codes , all