473,698 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

wxPython and thread memory problems?

Hi,

I took an example from wxPython with the IE web browser and
created a refresh button to automatically refresh a web page in 5
second intervals. But I notice that the memory utilization in Python
keeps increasing over time. Can anyone tell me why this is happening?
Here is my code:

=============== =============== =============== =============== =============== =

import wx, re
import time, thread
from urlparse import *

if wx.Platform == '__WXMSW__':
import wx.lib.iewin as iewin

refresh = 0

#----------------------------------------------------------------------

class TestPanel(wx.Pa nel):
def __init__(self, parent, frame=None):
wx.Panel.__init __(
self, parent, -1,
style = wx.TAB_TRAVERSA L |
wx.CLIP_CHILDRE N |
wx.NO_FULL_REPA INT_ON_RESIZE
)

self.current = "http://www.google.com"
self.frame = frame

if frame:
self.titleBase = frame.GetTitle( )

sizer = wx.BoxSizer(wx. VERTICAL)
btnSizer = wx.BoxSizer(wx. HORIZONTAL)

self.ie = iewin.IEHtmlWin dow(self, -1, style =
wx.NO_FULL_REPA INT_ON_RESIZE)

btn = wx.Button(self, -1, "Open", style=wx.BU_EXA CTFIT)
self.Bind(wx.EV T_BUTTON, self.OnOpenButt on, btn)
btnSizer.Add(bt n, 0, wx.EXPAND|wx.AL L, 2)

btn = wx.Button(self, -1, "Home", style=wx.BU_EXA CTFIT)
self.Bind(wx.EV T_BUTTON, self.OnHomeButt on, btn)
btnSizer.Add(bt n, 0, wx.EXPAND|wx.AL L, 2)

btn = wx.Button(self, -1, "<--", style=wx.BU_EXA CTFIT)
self.Bind(wx.EV T_BUTTON, self.OnPrevPage Button, btn)
btnSizer.Add(bt n, 0, wx.EXPAND|wx.AL L, 2)

btn = wx.Button(self, -1, "-->", style=wx.BU_EXA CTFIT)
self.Bind(wx.EV T_BUTTON, self.OnNextPage Button, btn)
btnSizer.Add(bt n, 0, wx.EXPAND|wx.AL L, 2)

btn = wx.Button(self, -1, "Stop", style=wx.BU_EXA CTFIT)
self.Bind(wx.EV T_BUTTON, self.OnStopButt on, btn)
btnSizer.Add(bt n, 0, wx.EXPAND|wx.AL L, 2)

btn = wx.Button(self, -1, "Search", style=wx.BU_EXA CTFIT)
self.Bind(wx.EV T_BUTTON, self.OnSearchPa geButton, btn)
btnSizer.Add(bt n, 0, wx.EXPAND|wx.AL L, 2)

btn = wx.Button(self, -1, "Refresh", style=wx.BU_EXA CTFIT)
self.Bind(wx.EV T_BUTTON, self.OnRefreshP ageButton, btn)
btnSizer.Add(bt n, 0, wx.EXPAND|wx.AL L, 2)

btn = wx.Button(self, -1, "AutoRefres h", style=wx.BU_EXA CTFIT)
self.Bind(wx.EV T_BUTTON, self.OnAutoRefr eshPageButton, btn)
btnSizer.Add(bt n, 0, wx.EXPAND|wx.AL L, 2)

txt = wx.StaticText(s elf, -1, "Location:" )
btnSizer.Add(tx t, 0, wx.CENTER|wx.AL L, 2)

self.location = wx.TextCtrl(sel f, -1, "",
style=wx.TE_PRO CESS_ENTER)

self.location.B ind(wx.EVT_CHAR , self.OnLocation Return)
btnSizer.Add(se lf.location, 1, wx.EXPAND|wx.AL L, 2)

sizer.Add(btnSi zer, 0, wx.EXPAND)
sizer.Add(self. ie, 1, wx.EXPAND)

self.ie.LoadUrl (self.current)

self.SetSizer(s izer)
# Since this is a wxWindow we have to call Layout ourselves
self.Bind(wx.EV T_SIZE, self.OnSize)

# Hook up the event handlers for the IE window
self.Bind(iewin .EVT_DocumentCo mplete, self.OnDocument Complete,
self.ie)

thread.start_ne w_thread(self.r efresh_url, (5,))

def OnSize(self, evt):
self.Layout()

def OnLocationRetur n(self, evt):
if evt.KeyCode() == wx.WXK_RETURN:
self.ie.Navigat e(self.location .GetValue(),
iewin.NAV_NoRea dFromCache | iewin.NAV_NoWri teToCache)
else:
evt.Skip()

def OnOpenButton(se lf, event):
dlg = wx.TextEntryDia log(self, "Open Location",
"Enter a full URL or local path",
self.current, wx.OK|wx.CANCEL )
dlg.CentreOnPar ent()

if dlg.ShowModal() == wx.ID_OK:
self.current = dlg.GetValue()
self.ie.Navigat e(self.current,
iewin.NAV_NoRea dFromCache | iewin.NAV_NoWri teToCache)

dlg.Destroy()

def OnHomeButton(se lf, event):
self.ie.GoHome( ) ## ET Phone Home!

def OnPrevPageButto n(self, event):
self.ie.GoBack( )

def OnNextPageButto n(self, event):
self.ie.GoForwa rd()

def OnStopButton(se lf, evt):
self.ie.Stop()

def OnSearchPageBut ton(self, evt):
self.ie.GoSearc h()

def OnRefreshPageBu tton(self, evt):
self.ie.Refresh Page(iewin.REFR ESH_COMPLETELY)

def OnAutoRefreshPa geButton(self, evt):
global refresh
refresh = not refresh

def refresh_url(sel f, delay):
global refresh
while (1):
time.sleep(dela y)
if refresh:
self.ie.Navigat e(self.ie._get_ LocationURL(),
iewin.NAV_NoRea dFromCache |
iewin.NAV_NoWri teToCache)

def OnDocumentCompl ete(self, evt):
self.current = evt.URL
self.location.S etValue(self.cu rrent)

class Frame(wx.Frame) :
def __init__(self, parent=None, id=-1, title='Title',
pos=wx.DefaultP osition, size=(640, 480)):
wx.Frame.__init __(self, parent, id, title, pos, size)

self.attr = {}
self.attr['panel'] = TestPanel(self)

class App(wx.App):
def OnInit(self):
self.attr = {}

self.attr['frame'] = Frame(title='My Window')
self.attr['frame'].Show()
self.SetTopWind ow(self.attr['frame'])

return True

def main():
app = App()
app.MainLoop()

if __name__ == '__main__':
main()
#----------------------------------------------------------------------

Jul 18 '05 #1
0 1374

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
5014
by: ulysses | last post by:
hi, I'm working in python 5 months. I think it's very cool language. I do a p2p python program GUI. First I make a software by wxpython. But I find wxpython use many many memory. Second I use PYQT. But memory use still big. But but but when I minimize the windows to taskbar, a fantasy something happened. memory use very very low when windows minimize.
25
2611
by: James Goldwater | last post by:
I'm starting a new hopfully-commercial project soon, and I face a dilemma about whether Python with wxPython would be appropriate. The project has 3 main areas: a) manipulation of lists and trees, using.. b) a hopefully dead-sexy gui, all in order to... c) eventually pump out certain bits of the datastructure over the network in semi-realtime (< 10ms accuracy or so).
6
2932
by: Zunbeltz Izaola | last post by:
Hi, I have the following problem. I'm developing a GUI program (wxPython). This program has to comunicate (TCP) whit other program that controls a laboratory machine to do a measurement. I have a dialog box, wiht two buttoms "Start measurement" and "Stop". "Start" executes a function that do the measurement in the following way.
22
5045
by: Glurt Wuntal | last post by:
I am a newbie with Python. It's a great language, but I would like to be able to present a simple gui menu for some of my scripts; something better than using 'raw_input' prompts. Any recommendations for a program that will allow me to create the gui screens? Something useable in Linux. thanks.
9
5548
by: zxo102 | last post by:
Hi everyone, I am using a python socket server to collect data from a socket client and then control a image location ( wxpython) with the data, i.e. moving the image around in the wxpython frame. But the "app.MainLoop()" in wxpython looks like conflicting with the "while 1:" in socket server. After I commented the "app.MainLoop()", everything is working except two things: 1. if I click anywhere on the screen with the mouse, the image is...
8
1683
by: Patrick Smith | last post by:
Hi, I'm hoping someone here will be able to help as I've been struggling with this problem for a few days now. I'm working on an application that is creating a ProgressDialog, and then creating a thread that runs a function from another module in the program. The problem is, when the cancel button on the ProgressDialog is pressed, the thread that was created continues to run. How can I make it so that when the cancel button on the...
3
1608
by: Shafik | last post by:
Hello folks, I'm having an issue with mixing wxPython and threading ... I realize multi-threading always introduces subtle bugs, but the following scenario is just odd: I start a dummy thread, that does nothing but increment a counter and print its value to the screen, then afterwards, I start the wxPython application. I get nothing but weird behavior: sometimes the gui just crashes, sometimes I get an exception, sometimes it runs for...
12
2173
by: bullockbefriending bard | last post by:
I am a complete ignoramus and newbie when it comes to designing and coding networked clients (or servers for that matter). I have a copy of Goerzen (Foundations of Python Network Programming) and once pointed in the best direction should be able to follow my nose and get things sorted... but I am not quite sure which is the best path to take and would be grateful for advice from networking gurus. I am writing a program to display horse...
16
2401
by: Andrea Gavana | last post by:
Hi Diez & All, Do you mind explaining "why" you find it *buttugly*? I am asking just out of curiosity, obviously. I am so biased towards wxPython that I won't make any comment on this thread in particular, but I am curious to know why some people find it "ugly" or "bad" or whatever. It has its own bugs and missing features, of course, but it is one of the major GUI player in the arena, together with PyQt and PyGTK.
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9023
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2327
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1999
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.