473,395 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Why is my wxPython code skipping steps

Hey everyone,

Below is my code for Python. The reason I'm using times is so that the program runs and then goes off a little bit in the future. So what I do is set the time about a minute later than the current time. Then I run the program and when it is time, the boxes come up. Sometimes they will go the current location fine, but other times, usually when the computer is doing something.. like if I am loading a video on youtube, etc...the boxes will freeze at random points before they get to the set location. What is going on here!

Also, the reason I have the time.sleep(0.5) in the while loop is because otherwise the program hogs up the computer's resources. Sorry for the sloppiness in the while loop.. just trying to test the code! Thanks everyone!

Expand|Select|Wrap|Line Numbers
  1. import wx
  2. import wx.lib
  3. import time
  4. import webbrowser
  5.  
  6. class Window ( wx.MiniFrame ):
  7.  
  8.    def __init__ ( self ):
  9.  
  10.         mini = wx.MiniFrame(None, -1, 'A Small Frame', pos=(wx.DisplaySize()[0]-250,wx.DisplaySize()[1]), size=(250,80), style=wx.STAY_ON_TOP)
  11.         mini.SetBackgroundColour("#506970")
  12.         mini5 = wx.MiniFrame(mini, -1, 'Background Part', pos=(wx.DisplaySize()[0]-250,wx.DisplaySize()[1]+15), size=(250,65), style=wx.STAY_ON_TOP)
  13.         mini5.SetBackgroundColour("green")
  14.  
  15.  
  16.         stepZZZ2 = wx.StaticText(mini, -1, "X" , pos=(250-14-3, 0), size = (14,14) )
  17.         stepZZZ2.SetForegroundColour("#F0F0F0")
  18.         stepZZZ2.SetFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.FONTWEIGHT_BOLD, False, u'Tahoma'))
  19.         stepZZZ2.SetCursor(wx.StockCursor(wx.CURSOR_HAND))
  20.         stepZZZ2.Bind(wx.EVT_LEFT_DOWN, lambda e, s=self: self.closeOut(mini))
  21.  
  22.  
  23.         str1 = "Random text"
  24.         step5a = wx.StaticText(mini, -1, str1 , wx.Point(5, 0))
  25.         step5a.SetFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Tahoma'))
  26.         step5a.SetForegroundColour("#F0F0F0")
  27.  
  28.  
  29.         stepZZZ = wx.StaticText(mini, -1, "X" , pos=(250-14-3, 0), size = (14,14) )
  30.         stepZZZ.SetForegroundColour("#F0F0F0")
  31.         stepZZZ.SetFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.FONTWEIGHT_BOLD, False, u'Tahoma'))
  32.         stepZZZ.SetCursor(wx.StockCursor(wx.CURSOR_HAND))
  33.         stepZZZ.Bind(wx.EVT_LEFT_DOWN, lambda e, s=self: self.closeOut(mini))
  34.  
  35.  
  36.         strALOT = "Random link"
  37.         step5z = wx.StaticText(mini5, -1, strALOT,  pos = (0,0), size=(250,65), style=wx.ALIGN_CENTER)
  38.         step5z.SetFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.FONTWEIGHT_BOLD, False, u'Tahoma'))
  39.         step5z.SetForegroundColour("black")
  40.         step5z.SetCursor(wx.StockCursor(wx.CURSOR_HAND))
  41.         step5z.Wrap(230)
  42.         step5z.Bind(wx.EVT_LEFT_DOWN, lambda e, s=self: s.loadLink())
  43.         step5z.SetPosition( (  (250-step5z.GetSize()[0])/2.0, (65-step5z.GetSize()[1])/2.0   ))
  44.  
  45.  
  46.         mini.Show(True)
  47.         mini5.Show(True)
  48.         currX = wx.DisplaySize()[0]-250
  49.         currY = wx.DisplaySize()[1]
  50.         currX2 = wx.DisplaySize()[0]-250
  51.         currY2 = wx.DisplaySize()[1]+15
  52.         for count in range(110):
  53.             step5a.Update()
  54.             step5z.Update()
  55.             stepZZZ.Update()
  56.             time.sleep(1/110.0)
  57.             mini.Move( (currX, currY-(count+1)) )
  58.             mini5.Move( (currX2, currY2-(count+1)) )
  59.  
  60.  
  61.         mini.Show ( True )
  62.         mini5.Show ( True )
  63.    def closeOut(self,mini2):
  64.       mini2.Destroy()
  65.    def loadLink(self):
  66.       webbrowser.open("http://www.google.com/")
  67.  
  68.  
  69.  
  70. application = wx.PySimpleApp()
  71. timelater=time.mktime((2008,12,28,9,2,30,362,5,-1))
  72. count=0
  73. donebefore="no"
  74. doit="no"
  75. while(True):
  76.     count=count+1
  77.     timenow=time.mktime(time.gmtime())
  78.     if(timenow > timelater and donebefore=="no"):
  79.        doit="yes"
  80.        donebefore="yes"
  81.     else:
  82.        doit="no"
  83.  
  84.     if(doit=="yes"):
  85.         Window()
  86.     time.sleep(.5)
  87.     application.MainLoop()   
  88.  
  89.  
Dec 28 '08 #1
0 1745

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Anand | last post by:
I am calling a python script from LabVIEW. This is achieved by making a dll call to python22.dll. It works perfectly well for most of my code. I now want to throwup dialog boxes from python. It...
1
by: wang xiaoyu | last post by:
Hello: i want use activex in wxpython program,but when i use MakeActiveXClass an exception occurs. this is my source code dealing the DICOM ocx.I must note that in this program "hwtxcontrol" is...
7
by: SeeBelow | last post by:
Do many people think that wxPython should replace Tkinter? Is this likely to happen? I ask because I have just started learning Tkinter, and I wonder if I should abandon it in favor of...
15
by: Grant Edwards | last post by:
Can anybody recommend a good book on wxPython? Are there any books on wxPython? I've been trying to learn wxPython and/or wax for a few weeks, and I'm just not getting it. wxWindows seems...
25
by: BJörn Lindqvist | last post by:
See: http://www.wxpython.org/quotes.php. especially: "wxPython is the best and most mature cross-platform GUI toolkit, given a number of constraints. The only reason wxPython isn't the standard...
13
by: Peter Maas | last post by:
Recently I replaced Win2k with Linux on my desktop computer. Using mostly multi-platform software I thought this would be easy. It was not as easy as expected getting wxPython to work. There seemed...
0
by: Robin Dunn | last post by:
Announcing ---------- The 2.6.3.0 release of wxPython is now available for download at http://wxpython.org/download.php. There have been many enhancements and fixes implemented in this...
0
by: Robin Dunn | last post by:
Announcing ---------- The 2.6.3.0 release of wxPython is now available for download at http://wxpython.org/download.php. There have been many enhancements and fixes implemented in this...
5
by: Brian Blais | last post by:
Hello, I have a wxPython program that I would like to give to a friend of mine who has a Mac. Is there a resource out there that can tell me what steps I need to follow to do this? Under...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.