Virgil Stokes | 8 Feb 23:37
Picon
Picon
Favicon
Gravatar

Some code that could be helpful in using wx.Overlay

With the help of Tim Roberts I have prepared some code that I hope will 
be useful for those of you who would like to know more about wx.Overlay. 
The code contains many comments which IMHO can be helpful when working 
with wx.Overlay.

--V

-- 
To unsubscribe, send email to wxPython-users+unsubscribe <at> googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
'''
Purpose: to show how wx.Overlay() can be used to draw an object then erase it 
         (recover the bitmap before the object was drawn on it).

  This code snippet can be quite useful for the development of a more complex
  interactive drawing package.

 Notes:
  1. wx.ClientDC --- draws to window (frame) object, the interior (client part)
  2. wx.PaintDC  --- similiar to wx.ClientDC, but only used when processing a 
                     wx.PaintEvent
  3. Code is heavily commented for my own purposes.                   
  4. Code has been tested with Python 2.6.6, wxPython 2.8.12.1 on both a Windows
     Vista and 7 platform. No anomalies have been observed.
  5. TESTMODE = True, will "print" additional information for test purposes.   
  
  Creator: V. Stokes (vs <at> it.uu.se)
  Version: 2012.02.08.02
'''
(Continue reading)

Ambyte | 8 Feb 14:28
Picon
Gravatar

Freezes window created with wxPython if use pyHook

This code works fine, however when I press minimize or close button,
window of program freezes on some time. The reason may be in the
HookMouse, without it, window minimize and close fine. Why?

import wx
import pyHook

class myFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, 'My Frame')
        self.tc=wx.TextCtrl(self, wx.ID_ANY, wx.EmptyString,
wx.DefaultPosition, wx.DefaultSize,
        wx.TE_MULTILINE|wx.TE_NOHIDESEL|wx.TE_READONLY)

        self.hm = pyHook.HookManager()
        self.hm.KeyDown = self.OnKeyboardEvent

        self.hm.HookKeyboard()
        self.hm.MouseLeftDown=self.OnKeyboardEvent
        self.hm.HookMouse()

        wx.EVT_CLOSE(self, self.OnClose)

    def OnGetAO(self, event):
        self.tc.Value+=event.MessageName+"\n"

    def OnKeyboardEvent(self, event):
        wx.CallAfter(self.OnGetAO, event)

    def OnClose(self, event):
(Continue reading)

月忧茗 | 8 Feb 18:05
Picon
Gravatar

How to auto expand Grid's column

Hi,


I defined a wx.grid.Grid object,
and then I added this object  into a StaticBoxSizer.


some code like bellow:

class DataPanel(wx.Panel):

......

self.init_test_grid()
       
_box = wx.StaticBox(self, -1, 'Box header')
sizer_wrap = wx.StaticBoxSizer(_box)
sizer_wrap.Add(self.grid, 1, wx.EXPAND)
       
self.SetSizer(sizer_wrap)




self.grid has 3 columns, and I want to self.grid full filled in it's parent.
means, 3 columns were auto expand based on parent's width,  not the value length in it.


How can I do this.
Please Help.


Thanks.

--
To unsubscribe, send email to wxPython-users+unsubscribe <at> googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
Picon
Favicon
Gravatar

UltimateListCtrl


Hello,
how insert  a check box in first column of UltimateListCtrl ?

This is my code:
        self.list.ClearAll()
        self.list.InsertColumn(0, _("Utente"))
        self.list.InsertColumn(1, _("Abilitato"))
        self.list.InsertColumn(2, _("Lettura"))
        self.list.InsertColumn(3, _("Modifica"))
        self.list.InsertColumn(4, _("Elimina"))

        self.bitmap = cBitmap("item_red_16.png")
        if self.idselezionato != None:
            s = cSqlSelect(self.conn)
            q = "SELECT ute_cod, ute_des, umnu_flag, umnu_read,
umnu_write, umnu_delete
 FROM utemnu LEFT JOIN utente ON umnu_utente=ute_cod WHERE umnu_menu=
%s"
            if not s.execute(q, [self.idselezionato]):
                self.error = s.error
                s.close()
            row = s.fetchall()
            utenti = {}
            mutenti = []
            i = 0
            for rs in row:
                u = []
                u.append(rs[0])
                u.append(rs[1])
                u.append(rs[2])
                u.append(rs[3])
                u.append(rs[4])
                u.append(rs[5])
                utenti[rs[0]] = u
                mutenti.append(rs[0])
                i = i + 1
            q = "SELECT ute_cod, ute_des FROM utente"
            if not s.execute(q):
                self.error = s.error
            row = s.fetchall()
            i = 0
            for rs in row:
                if rs[0] not in mutenti:
                    u = []
                    u.append(rs[0])
                    u.append(rs[1])
                    u.append(True)
                    u.append(True)
                    u.append(True)
                    u.append(True)
                    utenti[rs[0]]= u
                    i = i + 1
            s.close()
            items = utenti.items()
            index = 0
            self.il = wx.ImageList(16,16)
            bitmap = cBitmap("item_green_16.png")
            self.idx1 = self.il.Add(bitmap)
            self.il.Add(images.core.GetBitmap())
            self.il.Add(images.custom.GetBitmap())
            bitmap = cBitmap("item_red_16.png")
            self.idx2 = self.il.Add(bitmap)
            self.il.Add(images.expansion.GetBitmap())
            cont = 0
            self.list.SetImageList(self.il, wx.IMAGE_LIST_SMALL)
            for key, data in items:
                if cont < 40:
                    index =
self.list.InsertImageStringItem(sys.maxint, str(data[1]),[],
it_kind=1)
                    if data[2] != True:
                        self.list.SetStringItem(index, 1, "",
[self.idx2])
                    else:
                        self.list.SetStringItem(index, 1, "",
[self.idx1])
                    if data[3] != True:
                        self.list.SetStringItem(index, 2, "",
[self.idx2])
                    else:
                        self.list.SetStringItem(index, 2, "",
[self.idx1])
                    if data[4] != True:
                        self.list.SetStringItem(index, 3, "",
[self.idx2])
                    else:
                        self.list.SetStringItem(index, 3, "",
[self.idx1])
                    if data[5] != True:
                        self.list.SetStringItem(index, 4, "",
[self.idx2])
                    else:
                        self.list.SetStringItem(index, 4, "",
[self.idx1])
                    self.list.SetItemData(index, key)
                    index += 1
                    self.itemDataMap = utenti
                    cont = cont + 1

--

-- 
To unsubscribe, send email to wxPython-users+unsubscribe <at> googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Picon
Favicon
Gravatar

CustomTreeCtrl


Hello,
how you take all select checkbox in CustomTreeCtrl?

--

-- 
To unsubscribe, send email to wxPython-users+unsubscribe <at> googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

luvspython | 8 Feb 04:05
Picon
Gravatar

resizing sub-panels based on expanding controls

All,
    I am unable to get my head around how to have multiple sibling sub-
panels expand as needed, and would greatly appreciate advice on how to
accomplish this.

    In my real app, I have a Panel class containing a
UltimateListCtrl, and I have a stack of these panel objects in a
parent panel.  I want each subpanel to take only as much space as
required to show all rows in the list control (i.e., avoiding a
vertical scrollbar), and no more space than that (i.e., I don't want a
non-zero proportion when it's added to the parent's sizer) and I have
code that figures out the necessary vertical height to accomplish that
and sets the height of the panel. So the panel grows as I add rows.
This all works when I have a single such listctrl-panel.

    But things don't work when I have a stack of such panels; they
just don't grow.

    Below is a simplified example.  It doesn't use my listctrl-panel
because the demo gets big just with the complexity of adding rows to a
listctrl, so the panel in the example below uses an ExpandoTextCtrl
instead.  The subpanels are colored differerently to make things more
obvious, and it adds text to different subpanels every few seconds.

    There are some commented-out lines that only show a few of the
many things I've tried, to no avail.

    What I WANT to happen is as each sub-panel's Expando grows
vertically, that colored subpanel should grow so the entire Expando
shows.

    Any help will be GREATLY appreciated !

---------
import wx
import wx.lib.expando as EXP

class ExpandingPanel(wx.Panel):
    def __init__(self, parent, color):
        wx.Panel.__init__(self, parent, wx.ID_ANY)
        self.SetBackgroundColour(color)
        self.color = color
        #self.vertical = 40

        szrSelf = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(szrSelf)
        self.xtc = EXP.ExpandoTextCtrl(self, wx.ID_ANY, value=color +
'\n')
        szrSelf.Add(self.xtc, 0, wx.EXPAND|wx.ALL, 10)

    def AddText(self):
        self.xtc.SetValue( self.xtc.GetValue() + self.color + '\n')
        #self.vertical += 20
        #size = self.xtc.GetSize()
        #self.xtc.SetMinSize((size[0], self.vertical))
        self.xtc.SendSizeEvent()

if __name__ == '__main__':
    class F(wx.Frame):
        def __init__(self):
            wx.Frame.__init__(self, None, size=(500,700))

            self.pnl = pnl = wx.Panel(self, wx.ID_ANY)
            self.szrPnl = szrPnl = wx.BoxSizer(wx.VERTICAL)
            pnl.SetSizer(szrPnl)

            self.expPnl1 = ExpandingPanel(pnl, 'pink')
            self.expPnl2 = ExpandingPanel(pnl, 'green')
            self.expPnl3 = ExpandingPanel(pnl, 'blue')
            szrPnl.Add(self.expPnl1, 0, wx.EXPAND)
            szrPnl.Add(self.expPnl2, 0, wx.EXPAND)
            szrPnl.Add(self.expPnl3, 0, wx.EXPAND)

            self.pnlNum = 0
            wx.CallLater(2000, self.addMore)

        def addMore(self):
            self.pnlNum = (self.pnlNum + 1) % 3
            pnl = [self.expPnl1, self.expPnl2, self.expPnl3]
[self.pnlNum]
            pnl.AddText()

            # the 2 commented-out lines are from Robin's post here:
            # http://groups.google.com/group/wxpython-users/browse_thread/thread
            # /85dd6ed850096ed6/e2d5ee53a918e4ec?lnk=gst&q=resize
+subpanels#
            # but they don't change anything

            #size = pnl.GetSizer().GetMinSize()
            #self.szrPnl.SetItemMinSize(pnl, size)

            wx.CallLater(3000, self.addMore)
            self.Layout()

    app = wx.App()
    f = F()
    f.Show()
    app.MainLoop()

--

-- 
To unsubscribe, send email to wxPython-users+unsubscribe <at> googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Paul | 7 Feb 18:54
Picon

Remove TextCtrl focus indicator

Is there a way to remove the glow (I'm running on mac) when a TextCtrl gets 
focus?

I'm trying to vertically centralise the text in a TextCtrl, and to do it I'm 
using a TextCtrl with no border, painting white areas above and below it along 
with a border around it all, but the focus glow is breaking the illusion :P Is 
there a way to remove it with a style flag or anything?

Thanks!

Paul 

--

-- 
To unsubscribe, send email to wxPython-users+unsubscribe <at> googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Patrick Szabo | 7 Feb 16:10
Picon
Gravatar

Py2EXE

Hi,

I have a huge problem getting my wxpython app compiled with py2exe. I
found a lot of stuff on google and the main message is..go back to an
older version ie 2.8.11.0.
Can anyone tell me where to get that version of wxpython ?

btw I've tried everything to get my app running...right now the error
is

TypeError: sendMessage() takes exactly 2 arguments (3 given)

I import like this:

from wx.lib.pubsub import setupv1 as psv1
from wx.lib.pubsub import Publisher

and call like this:

Publisher.subscribe(Publisher(),self.updateDisplay, "update")

and

Publisher.sendMessage(Publisher(),"update", amt)

Help would be much appreciated.

best regards

--

-- 
To unsubscribe, send email to wxPython-users+unsubscribe <at> googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Virgil Stokes | 7 Feb 16:18
Picon
Picon
Favicon
Gravatar

How overlay works?

Would someone please provide the details of how overlay and its methods actually 
work.  I have found several nice examples that use overly; but, have found no 
documentation that actually explains the details of what happens "under the 
hood".  If such documentation exists, then a link to it would be greatly 
appreciated.

Here is an example that has been posted earlier and works fine (Python 2.6, 
Windows Vista).

import wx
print wx.version()

class TestPanel(wx.Panel):
     def __init__(self, *args, **kw):
         wx.Panel.__init__(self, *args, **kw)

         self.Bind(wx.EVT_PAINT, self.OnPaint)
         self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
         self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
         self.Bind(wx.EVT_MOTION, self.OnMouseMove)

         self.startPos = None
         self.overlay = wx.Overlay()

     def OnPaint(self, evt):
         # Just some simple stuff to paint in the window for an example
         dc = wx.PaintDC(self)
         coords = ((40,40),(200,220),(210,120),(120,300))
         dc.SetBackground(wx.Brush("sky blue"))
         dc.Clear()
         dc.SetPen(wx.Pen("red", 2))
         dc.SetBrush(wx.CYAN_BRUSH)
         dc.DrawPolygon(coords)
         dc.DrawLabel("Drag the mouse across this window to see \n"
                     "a rubber-band effect using wx.Overlay",
                     (140, 50, -1, -1))

     def OnLeftDown(self, evt):
         # Capture the mouse and save the starting posiiton for the
         # rubber-band
         self.CaptureMouse()
         self.startPos = evt.GetPosition()

     def OnMouseMove(self, evt):
         if evt.Dragging() and evt.LeftIsDown():
             rect = wx.RectPP(self.startPos, evt.GetPosition())

             # Draw the rubber-band rectangle using an overlay so it
             # will manage keeping the rectangle and the former window
             # contents separate.
             dc = wx.ClientDC(self)

             #***  This won't work because wx.GCDC is not a wx.WindowDC
             #dc = wx.GCDC(dc)

             odc = wx.DCOverlay(self.overlay, dc)
             odc.Clear()

             #***  This crashes on wxMac

             #dc = wx.GCDC(dc)

             dc.SetPen(wx.Pen("black", 2))
             if 'wxMac' in wx.PlatformInfo:
                 dc.SetBrush(wx.Brush(wx.Colour(0xC0, 0xC0, 0xC0, 0x80)))
             else:
                 dc.SetBrush(wx.TRANSPARENT_BRUSH)
             dc.DrawRectangleRect(rect)

             del odc # work around a bug in the Python wrappers to make
                     # sure the odc is destroyed before the dc is.

     def OnLeftUp(self, evt):
         if self.HasCapture():
             self.ReleaseMouse()
         self.startPos = None

         # When the mouse is released we reset the overlay and it
         # restores the former content to the window.
         dc = wx.ClientDC(self)
         odc = wx.DCOverlay(self.overlay, dc)
         odc.Clear()
         del odc
         self.overlay.Reset()

app = wx.App(redirect=False)
frm = wx.Frame(None, title="wx.Overlay Test", size=(450,450))
pnl = TestPanel(frm)
frm.Show()
app.MainLoop()

The comments help somewhat; but, they don't explain what is really happening in 
some of the code. For example,
if I comment out the self.overlay.Reset() in OnLeftUp(self, evt),  I can see no 
difference in the execution of the program.

Some basic questions (in reference to the above code):
1) What happens in odc.wx.DCOverlay(self.overlay,dc)? (note there are two instances)
2) What happens in odc.Clear()? (note there are two instances)
3) What happens in self.overlay.Reset() ? and Why is it used in this code?

--

-- 
To unsubscribe, send email to wxPython-users+unsubscribe <at> googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

Wonjun, Choi | 7 Feb 08:42
Picon

can I make f77 format editor by using stc?

hello
I wonder if I can make like this : http://ompldr.org/vY283cw
Is this possible?

Wonjun, Choi

--

-- 
To unsubscribe, send email to wxPython-users+unsubscribe <at> googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en

ErwinP | 6 Feb 22:53
Picon
Picon

UltimateListCtrl problem - border around last item not erased after delete

Hello,

I use a virtual UltimateListCtrl. When I delete the last item with the
Delete-Key, I call SetItemCount with the new item-count. The item is
deleted, but the border around the item is still visible. Is there
something wrong in my code ?
wx: 2.8.12.1, MSW

Sample:
import wx
import wx.lib.agw.ultimatelistctrl as ulc

class ULCVirtual(ulc.UltimateListCtrl):
    def __init__(self, parent, style, agwstyle):
        agwstyle |= ulc.ULC_VIRTUAL
        ulc.UltimateListCtrl.__init__(self, parent, -1,
              style=style, agwStyle=agwstyle)
    def OnGetItemColumnKind(self, item, column=0):
        return 0
    def OnGetItemText(self, item, col):
        return "item {0}".format(item)
    def OnGetItemToolTip(self, item, col):
        return "item {0}".format(item)
    def OnGetItemTextColour(self, item, col):
        return wx.NullColour
    def OnGetItemColumnCheck(self, item, column=0):
        return False
    def OnGetItemAttr(self, item_idx):
        return ulc.UltimateListItemAttr()

class TestFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, -1, "Test")
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)

        self.item_count = 5
        self.ulc = ULCVirtual(self,
            style=wx.NO_BORDER, agwstyle=ulc.ULC_REPORT)
        for i in range(2):
            self.ulc.InsertColumn(i, str(i))
        self.ulc.SetItemCount(self.item_count)
        sizer.Add(self.ulc, 1, wx.EXPAND)

        self.ulc.Bind(wx.EVT_LIST_KEY_DOWN, self.OnKeyDown)

    def OnKeyDown(self, event):
        keycode = event.GetKeyCode()
        if keycode == wx.WXK_DELETE:
            self.item_count -= 1
            self.ulc.SetItemCount(self.item_count)
        event.Skip()

app = wx.PySimpleApp()
TestFrame().Show()
app.MainLoop()

Regards,
Erwin

--

-- 
To unsubscribe, send email to wxPython-users+unsubscribe <at> googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en


Gmane