Python3 and wxpython
I cannot set up wxpython with pydev. In a python2 project I have had an external library /usr/lib/python2.7/dist-packages/wxPython-4.0.1-py2.7-linux-amd64.egg and it works fine. However, using the 'add zip/jar/egg/' option in my current version of pydev gives me no option to stop at the egg, but continues down to a file, eg.../PKG-INFO As a result I get 'no module named wx' error on compile. Copied egg to python3/dist-packages of course, but this doesn't work even if I add '/usr/lib/python3/dist-packages' explicitly. Can anyone explain ?
do you know?
how many words do you know
See also questions close to this topic
-
Find all nested SizerItems within a Frame in wxPython
In wxPython, I am trying to adjust the border of items within a form on startup programatically in order to support higher DPI displays a bit better. I want to do is loop through each item in the frame (i.e. each row as shown in the editor) and double the "border" attribute if it has one. This mostly works great. However, some sizers I'm unable to find programmatically, specifically those which are nested inside other sizers.
I've recreated this on a simplified form:
I have set the border of each item to unique values so that I know which ones have been hit.
- panel1: border of 1
- hiddenSizer: border of 2
- bSizer261: border of 3
- bSizer27: border of 4
- bSizer28: border of 5
- bSizer29: border of 6
- m_staticText29: border of 7
My code to (attempt to) find all SizerItems is the following:
import wx def walk_children(item): for value in item.GetChildren(): yield value for subvalue in walk_children(value): yield subvalue def adjust_border(frame : wx.Window): for x in walk_children(frame): print() sizer = x.GetContainingSizer() parents = [x] while parents[-1].GetParent(): parents.append(parents[-1].GetParent()) print(x, sizer) print(f"parents: {parents}") if sizer: for x in sizer.GetChildren(): print(x, x.GetBorder()) x.SetBorder(x.GetBorder() * 2) class MainFrameBase ( wx.Frame ): def __init__( self, parent ): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"My Window", pos = wx.DefaultPosition, size = wx.Size( 318,359 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) self.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_WINDOW ) ) bSizer1 = wx.BoxSizer( wx.HORIZONTAL ) self.panel1 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) bSizer23 = wx.BoxSizer( wx.VERTICAL ) hiddenSizer = wx.StaticBoxSizer( wx.StaticBox( self.panel1, wx.ID_ANY, u"Top Panel" ), wx.VERTICAL ) bSizer261 = wx.BoxSizer( wx.VERTICAL ) bSizer27 = wx.BoxSizer( wx.VERTICAL ) bSizer28 = wx.BoxSizer( wx.VERTICAL ) bSizer29 = wx.BoxSizer( wx.VERTICAL ) self.m_staticText29 = wx.StaticText( hiddenSizer.GetStaticBox(), wx.ID_ANY, u"MyLabel", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText29.Wrap( -1 ) bSizer29.Add( self.m_staticText29, 0, wx.ALL, 7 ) bSizer28.Add( bSizer29, 1, wx.ALL|wx.EXPAND, 6 ) bSizer27.Add( bSizer28, 1, wx.ALL|wx.EXPAND, 5 ) bSizer261.Add( bSizer27, 1, wx.ALL|wx.EXPAND, 4 ) hiddenSizer.Add( bSizer261, 1, wx.ALL|wx.EXPAND, 3 ) bSizer23.Add( hiddenSizer, 1, wx.ALL|wx.EXPAND, 2 ) self.panel1.SetSizer( bSizer23 ) self.panel1.Layout() bSizer23.Fit( self.panel1 ) bSizer1.Add( self.panel1, 1, wx.EXPAND |wx.ALL, 1 ) self.SetSizer( bSizer1 ) self.Layout() self.Centre( wx.BOTH ) def __del__( self ): pass class MainFrame(MainFrameBase): def __init__(self, parent): # initialize super().__init__(parent) self.Layout() adjust_border(self) def run_gui(): # create the window app = wx.App() ex = MainFrame(None) ex.Show() app.MainLoop() if __name__ == "__main__": run_gui()
The output is this which indicates only 3/7 of them haved been found (those with borders of 1, 3, and 7:
<wx._core.Panel object at 0x00000133C3DD91F8> <wx._core.BoxSizer object at 0x00000133C3DD0DC8> parents: [<wx._core.Panel object at 0x00000133C3DD91F8>, <__main__.MainFrame object at 0x00000133C3DD0D38>] <wx._core.SizerItem object at 0x00000133C3FA2708> 1 <wx._core.StaticBox object at 0x00000133C3DD5E58> <wx._core.StaticBoxSizer object at 0x00000133C3DD5EE8> parents: [<wx._core.StaticBox object at 0x00000133C3DD5E58>, <wx._core.Panel object at 0x00000133C3DD91F8>, <__main__.MainFrame object at 0x00000133C3DD0D38>] <wx._core.SizerItem object at 0x00000133C3FA2708> 3 <wx._core.StaticText object at 0x00000133C3FA24C8> <wx._core.BoxSizer object at 0x00000133C3FA2438> parents: [<wx._core.StaticText object at 0x00000133C3FA24C8>, <wx._core.StaticBox object at 0x00000133C3DD5E58>, <wx._core.Panel object at 0x00000133C3DD91F8>, <__main__.MainFrame object at 0x00000133C3DD0D38>] <wx._core.SizerItem object at 0x00000133C3FA2708> 7
How do I loop through each SizerItem in a frame programmatically without skipping entries?
There are similar questions like this, but the answers do not provide nested SizerItems. Generate List of All sizerItems Nested in wxPython Sizers
-
Creating an animation showing a line dropping vertically using wxPython
I wrote a code showing a line dropping vertically using wxPython. The issue Iam facing is when I keep the same y-coordinate (y2=y4 :drawing horizontal line on frame), the line is not visible on the window.
If I change the 4th parameter of the
DrawLine(...)
call by 1 unit (size[1]/2 -300+i*10
=>size[1]/2 -301+i*10
), the line is visible.Can anyone explain where Iam going wrong.
My code where I kept same y-coordinate to draw horizontal line is below. In this case, line is not visible.
import wx; import time; app = wx.App(); frame=wx.Frame(None,-1,'Line'); frame.SetBackgroundColour('White'); frame.Centre(); frame.Show(); frame.Maximize(); dc=wx.ClientDC(frame); size=dc.GetSize(); for i in range(1,50): dc.SetPen(wx.Pen('VIOLET')); dc.DrawLine(size[0] / 2-500, size[1]/2-300+i*10, size[0] / 2 , size[1]/2 -300+i*10); time.sleep(0.2); dc.SetPen(wx.Pen('WHITE')); # the pen is set to white and same line is drown to create the animation dc.DrawLine(size[0] / 2-500, size[1]/2-300+i*10, size[0] / 2 , size[1]/2 -300+i*10); app.MainLoop();
Now, if I change y-coordinate by even by 1 unit (y4=y2+1), the line is visible and the animation is shown on the frame. The code is below
import wx; import time; app = wx.App(); frame=wx.Frame(None,-1,'Line'); frame.SetBackgroundColour('White'); frame.Centre(); frame.Show(); frame.Maximize(); dc=wx.ClientDC(frame); size=dc.GetSize(); for i in range(1,50): dc.SetPen(wx.Pen('VIOLET')); dc.DrawLine(size[0] / 2-500, size[1]/2-300+i*10, size[0] / 2 , size[1]/2 -301+i*10); time.sleep(0.2); dc.SetPen(wx.Pen('WHITE')); # the pen is set to white and same line is drown to create the animation dc.DrawLine(size[0] / 2-500, size[1]/2-300+i*10, size[0] / 2 , size[1]/2 -301+i*10); app.MainLoop();
Can anyone explain why this difference or where Iam going wrong?
-
Align two differents graphs (ggplot) using same class of x axis but differents
i try to align two differents ggplot, using times series in x.axis (POSIXt) : one graph below the other one. I want the date to be perfectly aligned, despite the y labels that take place on the left for one and the legends take place on the right for the other one.
I have tried egg package, and cowboy package but they both use in their example a unique database, which seems to be simplier. And I don't make it with these one
Do you idea of some package than can help me with this case?
Thank you
-
Multiple 3d models are puted but only one is showing in unity3d
I had created a egg basket app to put a particular colour egg in that particular coloured basket but when I put multiple eggs with same colour in a basket only one egg is showing and the score is increasing as the number of baskets I put. Please guide me how I can make appear all eggs which are puted into basket...?