I'm quite new to tkinter (by new i mean I picked it up 2 hours ago) and so there is probably a really simple solution to this I'm just not seeing. But I want to clear a canvas so that I can redraw it. But I don't want to use delete as I then change the ID# of all the items as I redraw them. Is there a way to clear the canvas that retains the ID# of my items?
Thanks
I'm programing in Python 2.7 on Ubuntu 11.10.
So. It isn't clearing and redrawing that I want. it is the ability to move and configure items. The functions for which are:
Canvas.configureItem(TAGORID,OPTION=VALUE)
and
Canvas.move(TAGORID,distanceToMoveX,distanceToMoveY)
thanks for your insight Bryan. That was just the kick in the right direction I needed to figure it out.
To find out what the options are for configItem, call it with only a tag or an ID, it will return the appropriate options. for example, options for an oval are:
stipple
disabledoutlinestipple
activeoutlinestipple
dash
disabledwidth
dashoffset
activewidth
fill
disabledoutline
offset
disabledfill
disableddash
width
state
outlinestipple
disabledstipple
activedash
tags
activestipple
activeoutline
outlineoffset
activefill
outline
Related
I have a problem in which I update StaticText fairly often(once every second) and every time it updates, it tears the frame. This is very bothersome on Windows but on Linux it never happened. I tried doing TextCtrl Readonly but I get ugly boxes around text I was wondering if there was a better option for updating text in wxPython frequently that wouldn't tear the screen. Thanks in advance!
I wish I understood better what you meant by "tearing" the frame - I don't seem to have problems with changing StaticText values after a window is created (though sometimes it's necessary to call Layout on a Panel or Dialog).
However, if you're really just looking for read-only TextCtrl's without the "ugly boxes" you should use TextCtrl(style = wx.NO_BORDER | wx.TE_READONLY). The combination will give you what you want - what appears to be a StaticText, but that can't be user-edited and doesn't display a border. You'll also be able to select its value (which may or may not be an advantage).
Well i am creating a utility for my own needs, that being to help improve my reading on the computer. What i need to do is create a tool which can add a colour filter to a section of the screen, as well as add zoom. The first thing was easy to do, i set the attributes to add alpha, topmost and gave a frame a set bg colour.
What i dont know how to do is the zoom. I was thinking of getting a screen capture cut the selected bit apply image transformation then render it in the window. Of course the utility window will also be drawn and obscure the screen capture. I dont know tkinter well enough and i really want to avoid doing GDI work, but if someone has a solution with it i dont mind using it. Clearly referencing GDI, im making it to run on windows.
Optional: Something i have a work around for but would be nice to have is the ability to click through a window, but i doubt i can do that with tkinter.
EDIT: Since im getting negative votes, and i don't know why please help me improve with a comment.
I'm not looking for someone to do the work for me i just want a hint on what might be the right way to do this. With the main problem being how to get a image for whats underneath the Tkinter window so i can process it.
How can I auto scroll for the scroll area? For example, when there is a new update instead of the view of the scroll area staying the same, I want to go down with the new text. Think of it as in a CMD console, when you type a command it autoscroll with the output.
I was just going to respond to the other answer, but I just didn't know the best way to phrase it in the space allotted.
QScrollArea's are very useful widgets to use when designing custom PyQt widgets - I use them often. Things like rollout widgets, card widgets, anything where you could be displaying multiple sub-widgets with the need for scrolling can be a very useful utility. I don't agree with the idea that a QScrollArea isn't much use on its own.
The QTextEdit answer solves the problem the developer was facing - but only because it so happens the question is really about that. If you're trying to scroll a text edit, go with that answer.
However, if you are searching for an answer to the actual question and come across this thread, then the way to scroll down a QScrollArea is by actually modifying the scrollbar's value.
area = QScrollArea(parent)
vbar = area.verticalScrollBar()
vbar.setValue(vbar.maximum())
If you want to scroll to particular areas or anything (like implementing the ensureCursorVisible) then you want to take the location on the area's widget that you want to scroll to, figure out the percentage of the height of it, and apply that value to the vertical scrollbar. (Pseudocode)
Use QTextEdit.moveCursor to set the location you want to scroll to, and then use QTextEdit.ensureCursorVisible to scroll to it:
textedit.moveCursor(QtGui.QTextCursor.End)
textedit.ensureCursorVisible()
I am using Mac OS X 10.6.8, wxPython 2.9.3.1 and 64 Bit Python v2.7.2:
My problem is not that easy to describe in a few key words, thats why I probably did not find a solution yet.
I just just create a very simple wx.frame with some objects and arrange them with a sizer. If I then
show the frame all elements are displayed at top of each other for a second. Then everything jumps into place and is displayed correctly.
I tried to call all kinds of funktions before showing my frame like Refresh, wx.Yield, Update etc. but nothing helped.
Is there some function to prevent a frame to be shown before it is drawn correctly or to draw it but to not show it yet?
Thank you!
Typically when I see that issue, all that is needed is to call Layout right before you call the frame's Show() method. I would call Layout on the top sizer or the frame object. If that doesn't work, post a small runnable example and I'll update my answer.
I would like to create an application that has 3-4 frames (or windows) where each frame is attached/positioned to a side of the screen (like a task bar). When a frame is inactive I would like it to auto hide (just like the Windows task bar does; or the dock in OSX). When I move my mouse pointer to the position on the edge of the screen where the frame is hidden, I would like it to come back into focus.
The application is written in Python (using wxPython for the basic GUI aspects). Does anyone know how to do this in Python? I'm guessing it's probably OS dependent? If so, I'd like to focus on Windows first.
I don't do GUI programming very often so my apologies if this makes no sense at all.
As far as I know, there's nothing built in for this.
When the window is hidden, do you want it completely invisible or can a border of a few pixels be showing? That would be an easy way to get a mouse hover event. Otherwise you might have to use something like pyHook to get system-wide mouse events to know when to expand your window.
The events EVT_ENTER_WINDOW and EVT_LEAVE_WINDOW might also be useful here to know when the user has entered/left the window so you can expand/collapse it.
Expanding/collapsing can just be done by showing/hiding windows or resizing them. Standard window functions, nothing fancy.
By the way, you might want to use wx.ClientDisplayRect to figure out where to position your window. That will give you a rectangle of the desktop that does NOT include the task bar or any other toolbars the user has, assuming you want to avoid overlapping with those things.
Personally, I would combine the EVT_ENTER_WINDOW and EVT_LEAVE_WINDOW that FogleBird mentioned with a wx.Timer. Then whenever it the frame or dialog is inactive for x seconds, you would just call its Hide() method.
I think you could easily just make a window that is the same size as the desktop then do some while looping for an inactivity variable based on mouse position, then thread off a timer for loop for the 4 inactivity variables. I'd personally design it so that when they reach 0 from 15, they change size and position to become tabular and create a button on them to reactivate. lots of technical work on this one, but easily done if you figure it out