''' pwx_drag_frame101.py
experiments with wxPython's Frame styles
create a borderless window that is dragable

for Python3 downloaded project Phoenix latest version
for instance
wxPython_Phoenix-2.9.5.81-r74058-win32-py3.3.tar.gz
from
http://wxpython.org/Phoenix/snapshot-builds/
then simply extracted the wx folder to
C:\Python33\Lib\site-packages

tested with Python27/33 and wx(Phoenix) by  vegaseat  29may2013
'''

import wx

class DragFrame(wx.Frame):
    def __init__(self):
        style = wx.CLIP_CHILDREN|wx.STAY_ON_TOP|wx.FRAME_NO_TASKBAR|\
            wx.NO_BORDER|wx.FRAME_SHAPED
        wx.Frame.__init__(self, None, size=(300, 200), style=style)

        self.Bind(wx.EVT_KEY_UP, self.on_key_press)
        self.Bind(wx.EVT_MOTION, self.on_mouse)
        self.Bind(wx.EVT_PAINT, self.on_paint)
        self.SetTransparent(200)
        self.Show(True)

    def on_key_press(self, event):
        '''
        quit if user presses Esc key (27)
        '''
        if event.GetKeyCode() == 27:
            self.Close(force=True)
        else:
            event.Skip()

    def on_mouse(self, event):
        '''
        implement dragging
        '''
        if not event.Dragging():
            self._dragPos = None
            return
        self.CaptureMouse()
        if not self._dragPos:
            self._dragPos = event.GetPosition()
        else:
            pos = event.GetPosition()
            displacement = self._dragPos - pos
            self.SetPosition( self.GetPosition() - displacement )

    def on_paint(self, event):
        # wx.PaintDC() creates a drawing canvas
        dc = wx.PaintDC(self)
        # set the canvas background
        dc.SetBackground(wx.Brush('white'))
        dc.Clear()

        # wx.Brush(color, style)
        dc.SetBrush(wx.Brush('green', wx.CROSS_HATCH))
        # apply the brush to a rectangle
        dc.DrawRectangle(0, 0, 300, 200)
        # info
        s = "Drag me! \nPress Escape to exit"
        dc.DrawText(s, 20, 15)


app = wx.App(0)
frame = DragFrame()
app.MainLoop()
2
Contributors
2
Replies
40
Views
3 Years
Discussion Span
Last Post by vegaseat
0

hi , I did exactly as you said but I get this error
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import wx
File "c:\python33\lib\site-packages\wx__init__.py", line 17, in <module>
from wx.core import *
File "c:\python33\lib\site-packages\wx\core.py", line 6, in <module>
from ._core import *
ImportError: DLL load failed: The specified module could not be found.
any idea how to fix it

0

Strange, I don't have
c:\python33\lib\site-packages\wx__init__.py
but I have
c:\python33\lib\site-packages\wx\__init__.py

There is a DLL which you should have ...
c:\python33\lib\site-packages\wx\_core.pyd

I see, DaniWeb screws up \wx\_anything to \wx_anything unless it is in code

Edited by vegaseat

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.