LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-21-2009, 10:12 AM   #1
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Rep: Reputation: 56
wxwidgets / wxpython: how to erase a frame to avoid overpainting?


Hi

This is a really simple question, but so far I have not found a solution that works really.
I am not using dc contexts, but just a frame, a panel and a sizer. When I add text to a sizer, I need to clear that text away, because when I change the text on a new run, the old one is still there.
So far I tried to add an empty bitmap to the same position in the sizer, but that does not work.
How can I erase a sizer grid selectively?
I don't want to erase the whole frame with all widgets on it, since I need them still (menus and such).
Is there a way to erase a panel?

Markus
 
Old 02-21-2009, 11:08 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by browny_amiga View Post
When I add text to a sizer, I need to clear that text away
?!? Why?
Quote:
Originally Posted by browny_amiga View Post
[..] when I change the text on a new run, the old one is still there.
"on a new run"? What do you mean by "new run"?
Quote:
Originally Posted by browny_amiga View Post
So far I tried to add an empty bitmap to the same position in the sizer, but that does not work.
Sounds like you're doing something wrong with the sier or something like that.
Quote:
Originally Posted by browny_amiga View Post
How can I erase a sizer grid selectively?
Normally you would not need to do such things: just replace the string in the control: e.g. call SetText("new text") on your wx.StaticText object or whatever text-displaying-control you use. (what control do you use?)
Quote:
Originally Posted by browny_amiga View Post
I don't want to erase the whole frame with all widgets on it, since I need them still (menus and such).
There should be no need to..

Could you post some code? Without it and without information how you try to display text, and change it, and how your using the sizer etc, its' hard to say what is wrong.
 
Old 03-02-2009, 04:14 PM   #3
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Original Poster
Rep: Reputation: 56
>"on a new run"? What do you mean by "new run"?

>Sounds like you're doing something wrong with the
>sier or something like that.
>Normally you would not need to do such things:
> just replace the string in the control: e.g. call
> SetText("new text") on your wx.StaticText object >or whatever text-displaying-control you use. (what
>control do you use?)
>There should be no need to..

Aha, so you mean that I do the chain:
add statictext to sizer
when I change the text in statictext, it will automatically change in the sizer?
So far I was trying to add a new statictext to the sizer. Did not know that you can do it the way you described.

I have the same problem over and over: I am writing basically a tutoring appl, in which the user gets shown a text or picture (bitmap) and then has to react to it. Then, it is repeated with a new, random picture or text. Obviously I have to erase the old one. So far I found no way to do it.
Can I also do the trick with the static text with bitmaps? Add the bitmap to a sizer and then reassign to bitmap object to a new picture to have it automatically display in the sizer?

Is there a good book out there for Wxpython?
I think there is hardly any, so far I have not found some. But what about WxWidgets? Because that is the source, ain't it? Everything true to wxwidgets should be true in Wxpython, right?

The thing I am most interested in is the structures and snags: Wxwidgets is old and there is lots of old trash and irregularities inside. I ended up trying to use functions that were depreciated and did not realize it. Or there are 4 functions that seem to do the same things and the names are confusing.
A book about WxWidgets should clean that up.


>Could you post some code? Without it and without
> information how you try to display text,
>and change it, and how your using the sizer etc,
>its' hard to say what is wrong.[/QUOTE]

I would gladly do that, it is just that it is 500 lines long and don't expect people here to wade through endless lines of my code.

Markus
 
Old 03-02-2009, 05:15 PM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by browny_amiga View Post
Aha, so you mean that I do the chain:
add statictext to sizer
when I change the text in statictext, it will automatically change in the sizer?
So far I was trying to add a new statictext to the sizer. Did not know that you can do it the way you described.
Well. I'm not quite sure still what you mean by "change the sizer". But if I understand you correctly, then the answer is: yes, that is the only reason why sizers exist...

Quote:
Originally Posted by browny_amiga View Post
Can I also do the trick with the static text with bitmaps? Add the bitmap to a sizer and then reassign to bitmap object to a new picture to have it automatically display in the sizer?
Again, I don't really understand what you mean by "display in the sizer".[/quote]

The bitmap, button, staticText, .. whatever wx-control displays in a window (which is: wx.Frame, wx.Panel etc), not in a sizer.

A sizer controls the size of the wx-controls within the window (or possibly the size of the window too).

Quote:
Originally Posted by browny_amiga View Post
Is there a good book out there for Wxpython?
I think there is hardly any, so far I have not found some. But what about WxWidgets? Because that is the source, ain't it? Everything true to wxwidgets should be true in Wxpython, right?
The only book about wxWidgets is the book linked too from the wxWidgets website. But I suppose it is about the C++ library only. But usage of the library is basicaly the same for wxPython, since wx-python is a "just" a python module that maps all the classes and fucntions to the base C++ library below it.

All the documentation is written for C++, but it maps 1-to-1 to python 95% of the times. When there is an exception for python it there is a footnote.

Also deprecated functions are quite clearly documented AFAICS.

It is easier to read the docs if you know a bit about C++ though.

I also may help to read the python __doc__ of wx:
Code:
import wx
help(wx.StaticText)
 
Old 03-04-2009, 09:50 PM   #5
browny_amiga
Member
 
Registered: Dec 2001
Location: /mnt/UNV/Mlkway/Earth/USA/California/Silicon Valley
Distribution: Kubuntu, Debian Buster Stable, Windoze 7
Posts: 684

Original Poster
Rep: Reputation: 56
Now I get it, yes. I underestimated what OOP can do.
I before created a static text object, and added that to a sizer. Then, when the text changed, I created a new statictext and added that in the same position to the sizer.
Now, I can just reassign the old statictext object, that is already added to the sizer and through that the text is changed (displaywise).

Thanx for the pointer.


>The bitmap, button, staticText, .. whatever >wx-control displays in a window (which is: >wx.Frame, wx.Panel etc), not in a sizer.

I know that, but you set a sizer for a panel, so in a way it does display in a sizer (because the sizer defines the size and position it will get displayed)

>A sizer controls the size of the wx-controls
>within the window (or possibly the size of the
>window too).

Yeah, as you have said it already ;-)

>The only book about wxWidgets is the book linked
>too from the wxWidgets website. But I suppose it

Hmm, I know that one. But I am not so happy with that one, the way it is written. There must be commercial books, right? WXwidgets is ancient old, so there must be tons of them. I guess time to give amazon a spin.

>is about the C++ library only. But usage of the
>library is basicaly the same for wxPython, since
>wx-python is a "just" a python module that maps
>all the classes and fucntions to the base C++
>library below it.

Well, that is ok, I can deal with that.



>Also deprecated functions are quite clearly
>documented AFAICS.

Well, the documentation is not that accessible, at least not for me. I guess I am not really a programmer.
 
Old 03-05-2009, 02:29 AM   #6
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by browny_amiga View Post
I before created a static text object, and added that to a sizer. Then, when the text changed, I created a new statictext and added that in the same position to the sizer.
Now, I can just reassign the old statictext object, that is already added to the sizer and through that the text is changed (displaywise).
Why not just do:
Code:
# Create text object
TextObject = wx.StaticText(parent, -1, "This is the text displayed first")
# Add to sizer and so on..

# Then when it is time to change the text, just do:
TextObject.SetLabel("This is the new text")
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
wxwidgets / wxpython drawing problems with onPaint event browny_amiga Programming 5 02-13-2009 01:56 PM
how does pixel aspect relate to frame size in mplayer/how do you find vid frame size? BrianK Linux - General 3 10-31-2007 01:08 PM
installation of wxwidgets and wxpython on suse 10.1 noorudin Linux - Distributions 1 11-06-2006 03:49 AM
calling a frame from another frame : JAVA randomx Programming 0 10-07-2004 02:49 PM
XF86Config: how to avoid black frame : Suse 8.2 + new nvidia driver muellla Linux - Laptop and Netbook 3 08-09-2003 10:21 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration