Barak, Ron | 20 Aug 14:11

py2exe's setup.py for a wxPython application that incorporates a directory ?

Hi,
 
Has anyone a working py2exe configuration that can make a distribution package of a wxPython application ?
 
My application includes -
  1. the following modules:

    import wx                              
    import data                            
    from wx import xrc                 
    import getopt
    import sys
    import os

    from ErrorManager.ErrorManager import ErrorManager
    from ConnectivityManager.ConnectivityGraph import ConnectivityGraph
    from ConnectivityManager.ConnectivityGraphParser import ConnectivityGraphParser

    import generictable
    import message_box
    import grid_editor
    import graphic_svm_data
  2. an icons: SVM.ico
  3. and a directory tree '../dpm/save_state-ssp8400-E0023029_080401-154205'
 
I have two problems:
  1. I cannot find the correct syntax to include a directory in setup.py's "data_files" stanza (requirement (3) above)..
  2. when I run the py2exe built exe file, it crashes and the log includes the following, indicating that the wx module was not imported:

    Traceback (most recent call last):
      File "svm.py", line 6, in <module>
    ImportError: No module named wx
If you have a py2exe's setup.py for a wxPython application that incorporates a directory - could you show it to me ?
 
Thanks,
Ron.
_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Tom Harris | 20 Aug 11:38

Writing my own sizer

Greetings,

Is there an example of a custom Python sizer anywhere? I want to write
one like a GridSizer that adjusts the number of columns to fit the
width available.

Tom Harris -- celephicus(AT)gmail(DOT)com
_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Barak, Ron | 20 Aug 10:55

Re: I cannot make new values show in a grid cell, even though ForceRefresh() is called.

Hi Raffaello,
 
Sorry it took me awhile to create a demo of my post of 2008.08.17: "I cannot make new values show in a grid cell, even though ForceRefresh() is called." as requested.
 
Below is the program, with the 'offending' function:
 
    def OnGridCellChange(self, evt):
        row,col = evt.GetRow(),evt.GetCol()
        old_val = self.grid.GetTable().GetValue(row,col)
        new = self.grid.__dict__["changed_val"]
        self.grid.SetCellValue(row,col,new_val)
        self.grid.ForceRefresh()
        new_val = self.grid.GetTable().GetValue(row,col)
        print "row==",row,";col==",col,";old_val==",old_val,";new_val==",new_val,";new==",new
Where the print line demonstrate that the value is changed, but the grid itself is not updated on the screen (in spite of self.grid.ForceRefresh()).
 
Any suggestions would be welcome.
 
Bye,
Ron.
 
#!/usr/bin/env python
 
import wx
import wx.grid
import string
   
data = (("Bob", "Dernier"), ("Ryne", "Sandberg"),
        ("Gary", "Matthews"), ("Leon", "Durham"),
        ("Keith", "Moreland"), ("Ron", "Cey"),
        ("Jody", "Davis"), ("Larry", "Bowa"),
        ("Rick", "Sutcliffe"))
           
colLabels = ("Last", "First")
rowLabels = ("CF", "2B", "LF", "1B", "RF", "3B", "C", "SS", "P")
 
class SimpleGrid(wx.grid.Grid):
    def __init__(self, parent):
        wx.grid.Grid.__init__(self, parent, -1)
        tableBase = GenericTable(data, rowLabels, colLabels)
        self.SetTable(tableBase)                   
 
class TestFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "ForceRefresh() working ?",
                size=(275, 275))
        self.grid = SimpleGrid(self)
        self.BindTableEvents()
        self.grid.SetDefaultEditor(UpCaseCellEditor())
        self.grid.AutoSize()
 
    def OnGridCellChange(self, evt):
        row,col = evt.GetRow(),evt.GetCol()
        old_val = self.grid.GetTable().GetValue(row,col)
        new = self.grid.__dict__["changed_val"]
        self.grid.SetCellValue(row,col,new_val)
        self.grid.ForceRefresh()
        new_val = self.grid.GetTable().GetValue(row,col)
        print "row==",row,";col==",col,";old_val==",old_val,";new_val==",new_val,";new==",new
 
    def BindTableEvents(self):
        self.Bind(event=wx.grid.EVT_GRID_CELL_CHANGE, handler=self.OnGridCellChange, source=None)
 
    def SetDefaultCellEditor(self,grid):
        self.editor = grid.SetDefaultEditor(grid_editor.UpCaseCellEditor())
 
class UpCaseCellEditor(wx.grid.PyGridCellEditor):
    def __init__(self):
        wx.grid.PyGridCellEditor.__init__(self)
 
    def Create(self, parent, id, evtHandler):
        self._tc = wx.TextCtrl(parent, id, "")
        self._tc.SetInsertionPoint(0)
        self.SetControl(self._tc)
 
        if evtHandler:
            self._tc.PushEventHandler(evtHandler)
 
        self._tc.Bind(wx.EVT_CHAR, self.OnChar)
 
    def SetSize(self, rect):
        self._tc.SetDimensions(rect.x, rect.y, rect.width+2, rect.height+2,
                               wx.SIZE_ALLOW_MINUS_ONE)
 
    def BeginEdit(self, row, col, grid):
        self.startValue = grid.GetTable().GetValue(row, col)
        self._tc.SetValue(self.startValue)
        self._tc.SetInsertionPointEnd()
        self._tc.SetFocus()
        self._tc.SetSelection(0, self._tc.GetLastPosition())
 
    def EndEdit(self, row, col, grid):
        changed = False
 
        val = self._tc.GetValue()
       
        if val != self.startValue:
            changed = True
            grid.GetTable().SetValue(row, col, val)
            """
            The contents of 'val', could be retrieved from outside
            as: self.grid.__dict__["changed_val"]
            """
            grid.changed_val = val
 
        self.startValue = ''
        self._tc.SetValue('')
 
        return changed
 
    def Reset(self):
        self._tc.SetValue(self.startValue)
        self._tc.SetInsertionPointEnd()
 
    def Clone(self):
        return UpCaseCellEditor()
 
    def StartingKey(self, evt):
        self.OnChar(evt)
        if evt.GetSkipped():
            self._tc.EmulateKeyPress(evt)
 
    def OnChar(self, evt):
        key = evt.GetKeyCode()
        if key > 255:
            evt.Skip()
            return
        char = chr(key)
        if char in string.letters:
            char = char.upper()
            self._tc.WriteText(char)
        else:
            evt.Skip()
 
class GenericTable(wx.grid.PyGridTableBase):
           
    def __init__(self, data, rowLabels=None, colLabels=None):
        wx.grid.PyGridTableBase.__init__(self)
        self.data = data
        self.rowLabels = rowLabels
        self.colLabels = colLabels
       
    def GetNumberRows(self):
        try:
            return len(self.data)
        except (TypeError):
            pass

    def GetNumberCols(self):
        try:
            return len(self.data[0])
        except:
            pass
 
    def GetColLabelValue(self, col):
        if self.colLabels:
            return self.colLabels[col] 
 
    def IsEmptyCell(self, row, col):
        return False 

    def GetValue(self, row, col):
        try:
            return self.data[row][col]
        except:
            pass
 
    def SetValue(self, row, col, value):
        pass        
       
if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = TestFrame(None)
    frame.Show(True)
    app.MainLoop()
 
 
_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Chris Jones | 20 Aug 10:51

Manually setting wxAddCheckTool state possible?

Sorry if this is covered elsewhere, I searched documentation and google in vain for considerable time.

I am using a wxAddCheckTool toggle icon on my toolbar.  I would like to update its toggled state from another part of the code.  Is there any way to manually change its toggled state?  For example:

self.toggle = self.toolbar.AddCheckTool(self.ID_TOGGLE, icons.getTaggedBitmap())
self.frame.Bind(wx.EVT_TOOL, self.on_toolbar_toggle, self.toggle)

How can I manually change the self.toggle object to update its state?  The only promising-looking method was SetToggle, but this appears to change the ability to toggle it, not its actual state.

Is it just impossible? :/  I would accept workarounds such as manually firing events where such a state is mutable, if necessary.


--
Chris
_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Tony Ducrocq | 20 Aug 10:46

matplotlib panel resize troubles

Hello,

I'm trying to embed matplotlib figure in wxpython application but I
have troubles when resizing. If my windows become to big, a part of
the plot does not appear.
A screenshot : http://tonyducrocq.free.fr/err_matplotlib.png
Here is the code of panel :

#!/usr/bin/python
# -*- coding: utf-8 -*-
import wx

from matplotlib.figure import Figure
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg
from matplotlib.font_manager import FontProperties
import numpy

PLOT_FONT_SIZE = 9

class PlotsPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)
	self.fig = Figure()
        self.canvas = FigureCanvasWxAgg(self, -1, self.fig)
	self.Bind(wx.EVT_SIZE, self.OnSize)
	self.parent = parent
	
    def OnSize(self, event):
        size = self.parent.GetClientSize()
        self.fig.set_figwidth(size[0]/(1.0*self.fig.get_dpi()))
	self.fig.set_figheight(size[1]/(1.0*self.fig.get_dpi()))
	self.canvas.resize(size[0],size[1])
	self.canvas.draw()
        event.Skip()

class IdentityPanel(PlotsPanel):
    def plotMatrix(self,mat):
	self.mat = mat
        self.fig.clf()
        a = self.fig.add_subplot(111)
        self.im = a.imshow(mat, origin='lower', interpolation='nearest')
        self.fig.colorbar(self.im)
        self.canvas.draw()

    def onEraseBackground(self, evt):
        # this is supposed to prevent redraw flicker on some X servers...
        pass

Thanks by advance

--

-- 
Tony Ducrocq
_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

s7plc | 20 Aug 06:56

AUI_DockingWindowMgr in wxPython Demo

I am pretty new to wxPython, and am having a problem with AUI_DockingWindowMgr in the demo. My specific question concerns the tree control.

 

I have managed to populate the tree control that is displayed in the default frame layout with my own dynamic data, but don’t quite get where I would define the “EVT_TREE_SEL_CHANGED” event. I had it working fine when using the TreeCtrl under CoreWindows/Controls, but in the AUI_DockingWindowMgr the class structure and definitions have a different hierarchy, and I’m missing something. Another reason that I know I am not doing it correctly is that when I create another tree control with “View>Create Tree”, it just shows the same data as in the default tree control. Is this intentional?

 

It would be great if someone would first clarify where I would define the events for the default tree control, and then where I would define the root and associated data and events for the dynamic tree controls that are created from the menu. I am not looking for someone to do all of the work for me; I just need a jump start. Thanks!

_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

RichTextControl xml parsing error

Hello all!:
    I am writing an app which will use a RTC as editor. The development of it has begun under Python 2.5 and wxPython 2.8.7.1 under Linux (Ubuntu 8.04) and Windows XP without any more troubles than the usual due to try to use some new component.
    As part of the app, I get some HTML from a database, transform it to RTC-Kosher XML, and load into the control via LoadStream. Everything went OK even when I updated the wxPython version to 2.8.8.0 in both machines. But when the version of my Linux box got updated to 2.8.8.1, suddenly the RTC stopped recognizing as valid my XML, showing a message "XML parsing error: 'not well-formed (invalid token)' at line 1". The Win box (at job, and still using 2.8.8.0) runs the same code without a glitch. The line number is not useful because I pass the XML as only one long line.
    After some trials and errors, I reduced the problem to that the RTC does not accept unicode strings (u"text"), but only regular ones ("text").
    Attached goes a simple program that shows the unexpected behavior. The programs opens a frame showing a RTC loaded with some text, and a button that changes the text to a unicode string (no non-ascii chars in it).
    Should I post a bug report, or there is something that I am missing? The situation itself can be worked around easily changing the string to non-unicode before loading it to the RTC, but I was surprised for the change in behavior.

    Regards,
            Walter
Attachment (Frame1.py): text/x-python, 3760 bytes
_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Oliver Schoenborn | 20 Aug 03:01

pypubsub rc1: looking for stress testing

- I have found a way to support sendMessage/listener of pubsub "version
1" (the one in wxPython) without complexifying the API for "version 3"
users. However, the two types of sendMessage will not be mixable in an
application, and it's not yet in the latest release.

- I'm at rc1 of pypubsub 3 and I'm looking for fresh set of eyes/fingers
to try out the API and see who can find the most bugs ;)  Also, the
notification aspect (pubsub calls a handler when certain functions of
pubsub are called, such as when a listener subscribes, a topic is
created, etc), the exception traceback aspect, the "bad listener" error
messages, and the documentation, these could all benefit from
independent usage/feedback. Email me (schoenborno at users.sf.net) if
you'd like some ideas of how you could help.

- I'm also looking for some publish-subscribe design patterns, the most
difficult aspect of using any publish-subscribe architecture for
beginners. I'm adding a couple to the website but I'm sure there's many
more that would be useful to document.

BTW Thanks to all those who sent me info about their project(s) using
pubsub.

Cheers,
Oliver

_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

mcravitz | 19 Aug 19:38

wx.Choice Problems Windows/XP

I have noticed that when using Windows/XP in order to speed up loading of wx.Choice dropdowns it's
necessary to Freeze(), AppendItems, and then Thaw(). I did this and it sped things up considerably.
However, when I convert to an executable with PyToExe, the dropdown was empty even though I populated it
with 47 items. Has anybody experienced this problem? Is there a solution? Thanks,

Mike
_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
Steven Watanabe | 19 Aug 15:17

Safe to create wx gui objects in a non-gui thread?

We've got multiple threads in our application, the gui thread and worker threads. A worker thread wants to
display a modal dialog. I've read on this list that you can't call a wx gui function in a non-gui thread. But
is it safe to create a wx MessageDialog in a worker thread, pass it to the gui thread and let the gui thread
call ShowModal(), using a Python semaphore to block the worker thread until the result is available?

If it isn't, is there a recommended way to accomplish this?

Thanks. -Steven.
_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Tim van der Leeuw | 19 Aug 13:18

Writing Lexer for STC in Python?

Hi,

I'm wondering if it's possible to write a Lexer for the StyledTextControl (STC) in Python?

I fear that not, but if it would be possible, that would be rather cool :-)

Regards,

--Tim

_______________________________________________
wxpython-users mailing list
wxpython-users <at> lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Gmane