self.Refresh() doesn't do anything

I've looked up different methods of redrawing the window but none seem to do anything. Everytime I Show() a widget, I need to manually resize the window in order for it to redraw. Can someone suggest a better way of showing relevant widgets based on the selection in a listbox?

Here's my current code. http://pastebin.ca/1212792 but I don't think I'm doing things the right way. The ShowOptions() function is the important one.

Thanks in advance.

Durand wrote:

I've looked up different methods of redrawing the window but none seem to do anything. Everytime I Show() a widget, I need to manually resize the window in order for it to redraw. Can someone suggest a better way of showing relevant widgets based on the selection in a listbox?

Here's my current code. http://pastebin.ca/1212792 but I don't think I'm doing things the right way. The ShowOptions() function is the important one.
  

I suggest that you provide a running example with dependencies or at least provide links to the dependencies (temcs and config).

I can't see what is wrong by just looking at the code, so I tried to run it but could only do this after I created some globals to replace the config stuff and commented tremcs but I don't see how to cause ShowOptions() to run so I could see what goes wrong (might be because of my changes to get the code to run?!). So, maybe given a few steps on what one needs to do to see your problem might help.

Would also suggest to put a wx.Panel into your frame, at least on Windows it looks very odd, i.e. there are some grey areas showing where there are no controls.

Werner

Sorry, I thought my problem would be obvious as I am very new to wxpython. This is the whole program: http://durand.zephyrhosting.net/dump/tremcs.zip It is a script to get statistics for a game called tremulous but it's still in the preliminary stages. ShowOptions() is run when the "Show Stats" item in the list on the last tab is clicked. The last tab is supposed to be a collection of options. I'm trying to mimic the options dialog like in programs like The Gimp and Deluge which look like this: http://durand.zephyrhosting.net/dump/screen.png The idea is that when you click on an item in the list, it shows the relevant options.
Lastly, I have not tested this in Windows yet so I have no idea what it looks like there. I guess I will fix other problems later. The code I pasted is in the GUI.py file.

Thanks a lot for looking at this!

···

On Sun, 28 Sep 2008 16:34:18 +0100, Werner F. Bruhin <werner.bruhin@free.fr> wrote:

Durand wrote:

I've looked up different methods of redrawing the window but none seem to do anything. Everytime I Show() a widget, I need to manually resize the window in order for it to redraw. Can someone suggest a better way of showing relevant widgets based on the selection in a listbox?

Here's my current code. http://pastebin.ca/1212792 but I don't think I'm doing things the right way. The ShowOptions() function is the important one.

I suggest that you provide a running example with dependencies or at
least provide links to the dependencies (temcs and config).

I can't see what is wrong by just looking at the code, so I tried to run
it but could only do this after I created some globals to replace the
config stuff and commented tremcs but I don't see how to cause
ShowOptions() to run so I could see what goes wrong (might be because of
my changes to get the code to run?!). So, maybe given a few steps on
what one needs to do to see your problem might help.

Would also suggest to put a wx.Panel into your frame, at least on
Windows it looks very odd, i.e. there are some grey areas showing where
there are no controls.

Werner
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Werner F. Bruhin wrote:

Durand wrote:

I've looked up different methods of redrawing the window but none seem to do anything. Everytime I Show() a widget, I need to manually resize the window in order for it to redraw. Can someone suggest a better way of showing relevant widgets based on the selection in a listbox?

Here's my current code. http://pastebin.ca/1212792 but I don't think I'm doing things the right way. The ShowOptions() function is the important one.
  

I suggest that you provide a running example with dependencies or at least provide links to the dependencies (temcs and config).

In other words, read this and follow what it suggests: http://wiki.wxpython.org/MakingSampleApps

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Durand wrote:

Sorry, I thought my problem would be obvious as I am very new to wxpython.

1) try and Update() after the Refresh() -- Refresh() only tells the system that the window needs re-drawing -- it doesn't make it happen.

This is the whole program: http://durand.zephyrhosting.net/dump/tremcs.zip

2) that is way too much work for me to go check out -- make a small, self contained sample app, as Robin (and others) have suggested.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Ok, I tried what you suggested and came up with this: http://pastebin.ca/1218144 However, the problem is that it does work here...(self.Update() isn't needed)Well, there is actually a space next to the list in the sample code which is not in the full program and I have no idea why... I guess you guys have helped me enough already...

Ok, another question, is this mailing list on google groups? It's kinda difficult to track all the relevant messages with a mail client though Opera does do a good job.

Thanks

···

On Tue, 30 Sep 2008 06:02:14 +0100, Christopher Barker <Chris.Barker@noaa.gov> wrote:

Durand wrote:

Sorry, I thought my problem would be obvious as I am very new to wxpython.

1) try and Update() after the Refresh() -- Refresh() only tells the
system that the window needs re-drawing -- it doesn't make it happen.

This is the whole program: http://durand.zephyrhosting.net/dump/tremcs.zip

2) that is way too much work for me to go check out -- make a small,
self contained sample app, as Robin (and others) have suggested.

-Chris

Durand wrote:

Ok, I tried what you suggested and came up with this:
http://pastebin.ca/1218144 However, the problem is that it does work
here...(self.Update() isn't needed) I guess you guys have helped me enough
already...

That's the idea -- now you need to add stuff back in until the problem
shows up again.

By the way, it's easier to just enclose the code with your post -- one
less step for folks to try it out for you.

> Well, there is actually a space
> next to the list in the sample code which is not in the full program
> and I have no idea why...

Actually, for me, on OS-X, with wxPython 2.8.9.1, the layout is a mess, and I can't tell what it should be.

A couple comments:

I'd stay away form exec() it's dangerous and fragile -- it also muddles up the distinction between code and data:

         for widget in hidden_widgets:
             exec("extra_opts_options_sizer.Add(self.%s)"%(widget))

could be:

# in __init__
hidden_widgets = [self.save_stats_opts_activate,
                   self.save_stats_opts_destroy]

then:
# in __do__layout
         for widget in hidden_widgets:
             extra_opts_options_sizer.Add(widget)

Things are getting pretty nested:

         self.main_opts = wx.Notebook(self, -1, style=0)
         # Notebook Panes
         self.main_opts_pane = wx.Panel(self.main_opts, -1)
         self.extra_opts_pane = wx.Panel(self.main_opts,-1)
         self.extra_options_listbox = wx.ListBox(self.extra_opts_pane, -1, choices=["Option"])

so you've got a Frame with a Notebook on it, and a couple Panels in that Notebook.

What I'd do is make each of those Panels a separate class. You might also want to make the notebook a separate class.

That way, you can test each panel by itself, and you won't get as confused about what is the parent of what.

Take a look at:

http://wxpython.org/codeguidelines.php
and
http://wiki.wxpython.org/wxPython%20Style%20Guide

for style guidelines. It will help make your code cleaner and more readable.

Ok, another question, is this mailing list on google groups?

I don't think so, but it is on gmane, that might be easier for you.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Ok, I'll try those tips, thanks :slight_smile:

···

On Fri, 03 Oct 2008 19:13:19 +0100, Christopher Barker <Chris.Barker@noaa.gov> wrote:

Durand wrote:

Ok, I tried what you suggested and came up with this:
http://pastebin.ca/1218144 However, the problem is that it does work
here...(self.Update() isn't needed) I guess you guys have helped me enough
already...

That's the idea -- now you need to add stuff back in until the problem
shows up again.

By the way, it's easier to just enclose the code with your post -- one
less step for folks to try it out for you.

> Well, there is actually a space
> next to the list in the sample code which is not in the full program
> and I have no idea why...

Actually, for me, on OS-X, with wxPython 2.8.9.1, the layout is a mess,
and I can't tell what it should be.

A couple comments:

I'd stay away form exec() it's dangerous and fragile -- it also muddles
up the distinction between code and data:

         for widget in hidden_widgets:
             exec("extra_opts_options_sizer.Add(self.%s)"%(widget))

could be:

# in __init__
hidden_widgets = [self.save_stats_opts_activate,
                   self.save_stats_opts_destroy]

then:
# in __do__layout
         for widget in hidden_widgets:
             extra_opts_options_sizer.Add(widget)

Things are getting pretty nested:

         self.main_opts = wx.Notebook(self, -1, style=0)
         # Notebook Panes
         self.main_opts_pane = wx.Panel(self.main_opts, -1)
         self.extra_opts_pane = wx.Panel(self.main_opts,-1)
         self.extra_options_listbox = wx.ListBox(self.extra_opts_pane,
-1, choices=["Option"])

so you've got a Frame with a Notebook on it, and a couple Panels in that
Notebook.

What I'd do is make each of those Panels a separate class. You might
also want to make the notebook a separate class.

That way, you can test each panel by itself, and you won't get as
confused about what is the parent of what.

Take a look at:

http://wxpython.org/codeguidelines.php
and
http://wiki.wxpython.org/wxPython%20Style%20Guide

for style guidelines. It will help make your code cleaner and more readable.

Ok, another question, is this mailing list on google groups?

I don't think so, but it is on gmane, that might be easier for you.

-Chris

Durand,

···

On Tue, 30 Sep 2008 06:02:14 +0100, Christopher Barker <Chris.Barker@noaa.gov> wrote:

Durand wrote:
    

Sorry, I thought my problem would be obvious as I am very new to wxpython.
      

1) try and Update() after the Refresh() -- Refresh() only tells the
system that the window needs re-drawing -- it doesn't make it happen.

This is the whole program: http://durand.zephyrhosting.net/dump/tremcs.zip
      

2) that is way too much work for me to go check out -- make a small,
self contained sample app, as Robin (and others) have suggested.

-Chris

Ok, I tried what you suggested and came up with this: http://pastebin.ca/1218144 However, the problem is that it does work here...(self.Update() isn't needed)Well, there is actually a space next to the list in the sample code which is not in the full program and I have no idea why... I guess you guys have helped me enough already...

Ok, another question, is this mailing list on google groups? It's kinda difficult to track all the relevant messages with a mail client though Opera does do a good job.

Thanks

Maybe this will help: http://lists.wxwidgets.org/pipermail/wxpython-users/

Supposedly, you can use Thunderbird to do it too as it supports groups of posts automagically too.

Mike

Yeah, I do use that and Opera groups posts but its still a massive clump. I guess I'm just being picky. Google groups is very neat and easy to use.

Durand,

<snip>

···

On Fri, 03 Oct 2008 19:17:15 +0100, Mike Driscoll <mike@pythonlibrary.org> wrote:

On Tue, 30 Sep 2008 06:02:14 +0100, Christopher Barker <Chris.Barker@noaa.gov> wrote:

Ok, I tried what you suggested and came up with this: http://pastebin.ca/1218144 However, the problem is that it does work here...(self.Update() isn't needed)Well, there is actually a space next to the list in the sample code which is not in the full program and I have no idea why... I guess you guys have helped me enough already...

Ok, another question, is this mailing list on google groups? It's kinda difficult to track all the relevant messages with a mail client though Opera does do a good job.

Thanks

Maybe this will help: http://lists.wxwidgets.org/pipermail/wxpython-users/

Supposedly, you can use Thunderbird to do it too as it supports groups
of posts automagically too.

Mike

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Durand wrote:

Yeah, I do use that and Opera groups posts but its still a massive clump. I guess I'm just being picky. Google groups is very neat and easy to use.
  
My main issue with Google Groups is that Google allows the spambots to go crazy on it and you end up with huge waves of garbage every couple of months. I'm not sure if Nabble has that issue or not...of course, they might not be mirroring wxPython posts like they do c.l.py ones either

- Mike

···

On Fri, 03 Oct 2008 19:17:15 +0100, Mike Driscoll <mike@pythonlibrary.org> wrote:

Durand,

On Tue, 30 Sep 2008 06:02:14 +0100, Christopher Barker <Chris.Barker@noaa.gov> wrote:

<snip>
  

Ok, I tried what you suggested and came up with this: http://pastebin.ca/1218144 However, the problem is that it does work here...(self.Update() isn't needed)Well, there is actually a space next to the list in the sample code which is not in the full program and I have no idea why... I guess you guys have helped me enough already...

Ok, another question, is this mailing list on google groups? It's kinda difficult to track all the relevant messages with a mail client though Opera does do a good job.

Thanks

Maybe this will help: http://lists.wxwidgets.org/pipermail/wxpython-users/

Supposedly, you can use Thunderbird to do it too as it supports groups
of posts automagically too.

Mike

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Durand wrote:

Ok, another question, is this mailing list on google groups? It's kinda difficult to track all the relevant messages with a mail client though Opera does do a good job.

Try Gmane: http://dir.gmane.org/gmane.comp.python.wxpython

It lets you send/receive group messages via NNTP (USENET news) clients, or you can read via the web with a threaded multi-pane UI. Not as fancy as Google Groups, but it works fairly well.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

I can't run the code because of missing imports... try making smaller example

but that problem sounds indeed familiar... try self.Layout() or x.Layout()
on your x panel what have to refreshed :slight_smile:

···

--
View this message in context: http://www.nabble.com/self.Refresh()-doesn't-do-anything-tp19711880p19833298.html
Sent from the wxPython-users mailing list archive at Nabble.com.