Member Avatar

I have a wx.DatePickerCtrl with the dropdown popup window that allows the user to pick a date from the calendar. What I would l like to have my program do is process an event when the user has clicked on a day in the dropdown calendar. Unfortunately the only native event for this control is EVT_DATE_CHANGED and that event gets fired every time the user scrolls the month/year while looking for the date of their choice (firing the event many more times than I would like). I can't seem to access the popup window that is created below the datepickerctrl …

Member Avatar
0
35
Member Avatar

I stumbled on upon this anomaly in one of my programs and can't figure out why this is happening. I made a small test function that exhibits the same behavoir. It's like the local variables of my function are being saved after the function exits. The exclude_ids variable keeps growing. This same behavoir is apparent in IDLE, from cmd line, and when compiled. Tested on windows XP & 8. Python 2.7.4 >>> def is_running(exe_name, by_path=False, exclude_ids=[], exclude_this_process=False): from os import getpid from os.path import basename, abspath if exclude_this_process: exclude_ids.append(getpid()) print "exluded ids %s" % exclude_ids return "-----------------" >>> for x …

Member Avatar
0
58
Member Avatar

I'm soliciting advice for performace improvements for creating a weak checksum for file segments (used in the rSync algorithm) Here's what I have so far: def blockchecksums(instream, blocksize=4096): from hashlib import md5 weakhashes = [] stronghashes = [] for chunk in iter(lambda: instream.read(blocksize),""): a = b = 0 l = len(chunk) for n, i in enumerate(bytes(chunk)): a += i b += (l - n)*i weakhashes.append((b << 16) | a) stronghashes.append(md5(chunk).hexdigest()) return weakhashes, stronghashes I haven't had any luck speeding things up using itertools or using c functions (like any() )

Member Avatar
0
32
Member Avatar

I came across this project that could be really helpful.. if I was c++ literate. I know enough c++ to be dangerous and thats about it. Thanks in advance for anyone who wants to take a crack at it. ps credit to: http://www.codeproject.com/Articles/13839/How-to-Prepare-a-USB-Drive-for-Safe-Removal

Member Avatar
0
3
Member Avatar

I'm trying to create a wx.ListCtrl with a searchable header. I've been looking through the listctrl mixins, but I really don't have the wx expertise needed. I'm thinking I need to paint a textctrl using a dc object, but other than that I'm lost. Any ideas?

0
1
Member Avatar

I'm doing some research to determine the most efficient way to copy files. I've got 3 candidate functions: #1 [CODE=python] # uses generator to load segments to memory def copy(src, dst, iteration=1000): for x in xrange(iteration): def _write(filesrc, filedst): filegen = iter(lambda: filesrc.read(16384),"") try: while True: filedst.write(filegen.next()) except StopIteration: pass with open(src, 'rb') as fsrc: with open(dst, 'wb') as fdst: _write(fsrc, fdst)[/CODE] #2 [CODE=python] # loads entire file to memory def copy2(src, dst, iteration=1000): for x in xrange(iteration): with open(src, 'rb') as fsrc: with open(dst, 'wb') as fdst: fdst.write(fsrc.read())[/CODE] #3 [CODE=python] def copy3(src, dst, iteration=1000): for x in xrange(iteration): with …

Member Avatar
0
8
Member Avatar

Just wanted to point out for anyone using py2exe that it apparently doesn't always (or maybe ever) raise AssertionErrors. It's been a while since they've updated the program so it's probably just easier to implement a workaround for those of us who use this compiler. I've noticed it not raising the error in a variety of circumstances. Here's the workaround I implemented. python 2.7.2 py2exe 0.6.9 [CODE=python]def _assert(assertion): # workaround for py2exe not # raising assertion errors if not assertion: raise AssertionError[/CODE] ps please don't lecture me on why I shouldn't use assert

0
1
Member Avatar

I've been working with python's SocketServer.ThreadingTCPServer a bit and I'm having some difficulty making a publicly available server. Everything works fine when I set the server address as 'localhost' [CODE=python]self.server = SocketServer.ThreadingTCPServer(('localhost', constants.cmdport), Handler)[/CODE] As long as the both the server and client are on the same computer and both specify 'localhost' the connections are made without a hitch. My program uses [URL="http://pypi.python.org/pypi/pystun"]pystun[/URL] to obtain my public ip. When I pass that public ip to the client and try to make a connection over the internet I get [errno 10061] No connection could be made..... as if the port was …

Member Avatar
0
6
Member Avatar

I made a simple ThreadManager class that receives tasks and spawns threads to complete the tasks. Currently it keeps all the threads alive until I explicitly set threadmgr.waiting=False and all of the tasks are complete. I'm trying to eliminate the need for the former. What I would prefer is that when the frame that instantiates the threadmgr terminates it automatically tells the threadmgr to stop waiting for new tasks. I've been looking at the inspect module and am able to get a line number that the parent frame is on but I don't see an easy way to determine if …

Member Avatar
0
3
Member Avatar

Currently running python 2.7 on windows 7. I have an app created with wx python and compiled with py2exe. This app has an update utility that polls an update server at startup. If an update is found it downloads the new executable file (approx. 7mb) and makes the switch. It works well, but when I change 3 lines of code and publish an update the end user has to again download an entire 7+ mb file. I know that py2exe creates a zip archive containing the .pyo's and I would like to be able to add/remove/overwrite those .pyo files while …

0
1
Member Avatar

how do I catch changes to a mutable object ie: [CODE=python] class test(object): def __init__(self): self.x = [] def __getattr__(self, atr): print 'retrieving atr %s' % atr return self.__dict__[atr] def __setattr__(self, atr, val): print 'setting atr %s to value % s' % (atr, val) self.__dict__[atr] = val [/CODE] >>> instance = test() >>> instance.x.append(1) >>> # doesn't print anything, b/c the change is made in place # any ideas of how to catch that?

Member Avatar
0
6
Member Avatar

Anyone work with UltimateListCtrl's before? I'm looking for a way to dynamically change the column headers background color.

0
1
Member Avatar

I'm having a hard time getting my website to email the contents of form. It will send an email with the field labels but no values.. ie name: phone number: email: from: () the only thing I can get it to return is the ip Here is the relevant html [CODE=html]<form id="FORMOB7DB261A1233A5C2" name="Form1" action="contact_us/formtoemail.php" enctype="text/plain" method="POST" onsubmit="return validateForm(this)" onreset="return confirm('Do you really want to reset the form?')" > <input type="hidden" value="0" name="to"/> <input type="hidden" value="A message from www.mysite.com" name="subject"/> <input type="hidden" value="messenger@mysite.com" name="from"/> <input type="hidden" value=""<?php echo $ipi ?>"" name="ip"/> <input type="hidden" value=""<?php echo $httprefi ?>"" name="httpref"/> <input type="hidden" value=""<?php …

0
1
Member Avatar

How do you keep a wx frame from not responding while the code is running in the background? ie a search or other demanding function.

Member Avatar
0
7
Member Avatar

why does this fail to call any event? [CODE=python] def StartTimer(self, timer = 1): timer_data = { 1: (self.TimeKeeper, False, 50), 2: (self.InterimSearch, True, 200), 3: (self.InterimCurSearch, True, 200), 4: (self.SetOpaque, False, 50), 5: (self.DisplayPhoto, True, 200) } function, singlefire, time = timer_data[timer] timer = str(timer) # class of constants ID = eval('con.TIMER'+timer) exec('timer = self.t'+timer+' = wx.Timer(self, id=ID)') timer.Bind(wx.EVT_TIMER, Dispatcher(function), id=ID) timer.Start(time, singlefire) self.Timers[timer] = 1[/CODE] [CODE=python]class Dispatcher: """ An intermediary between binded events and there routines. Allows altering of routines without destroying the initial references """ def __init__(self, aFunction): import __main__ self.name = aFunction.__name__ if hasattr(aFunction, 'im_self'): self.container …

0
1
Member Avatar

Is there a way to set an objects id or memory position? Ultimately I'm trying to change function "a" to function "b" while still preserving any saved reference to function "a"

Member Avatar
0
8
Member Avatar

I've been using the Aspects module to trace and patch routines on the fly in my wxPython app. The problem I've run in to occurs when wx binds an event to a function. ie: an event is binded to function <function func at 0x03969A30> after aspects.with_wrap() func now becomes <function func at [B][I]0x03973030[/I][/B]> the namespace is updated but is seems that wx maintains a copy of the old function in memory rather than just a reference. When the event is triggered the old routine is called rather than the new 'patched' one. So far the only dependable way to fix …

0
1
Member Avatar

In order for my code to be efficient, loops need to be terminated prematurely to prevent unnecessary iterations. I know that list comprehension is fast that the 'for' statement, but I'm having trouble finding a suitable way to break them. Here's what I've come up with [CODE=python]try: [x if x < 5 else 1/0 for x in range(5)] except: pass [0, 1, 2, 3, 4][/CODE] I'm just using an exception to break it.

Member Avatar
0
13
Member Avatar

I wrote this function to compare two strings and find their similarity. It returns the percent of their letters in common in place. ie "hello" and "yellow" share the "ello" (8 of 11 characters) and thus are 72.72 % similar. I feel like there is a better way to write this but I've yet to come up with it. [CODE=python] def RunComparison(str1, str2, param): comp = Compare(str1, str2, param) return comp.percent class Compare: def __init__(self, str1, str2, param): self.str1 = str1.lower() self.str2 = str2.lower() self.param = param self.most = 0 self.percent = self.LIC() def LIC(self): # Letters in common only …

Member Avatar
0
53
Member Avatar

Can anyone think of an intelligent way to extract the largest sequence of numbers from a list like: [CODE=python][[2, 4, 9], [3, 5, 10], [6], [2, 4, 9], [1, 8, 11], [3, 5, 10], [6], [2, 4, 9], [0, 7], [1, 8, 11]][/CODE] without brute forcing every possibility. You can only use one number from each nested list and you have to move forward down the main list. ie you could use the '2' from nested list one and the '3' from nested list two. You could use the '6' from nested list 3, but that would limit you to …

Member Avatar
0
8
Member Avatar

Does anyone know of a way to change a property from read-only to writable on the fly without changing the source?[CODE=python] >>> p = property(lambda self: self.__p) >>> p.fset = lambda self: self.__p Traceback (most recent call last): File "<pyshell#19>", line 1, in <module> p.fset = lambda self: self.__p TypeError: readonly attribute[/CODE]

Member Avatar
0
2
Member Avatar

[CODE=python]>>> import wx >>> wx.NullBitmap.SubBitmap Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> wx.NullBitmap.SubBitmap File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_gdi.py", line 659, in GetSubBitmap return _gdi_.Bitmap_GetSubBitmap(*args, **kwargs) TypeError: Bitmap_GetSubBitmap() takes exactly 2 arguments (1 given)[/CODE] I didn't call it, I just tried to reference it. happens with all these methods wx.DefaultDateTime.Day wx.NullBitmap.SubBitmap wx.NullBrush.Colour wx.NullFont.Encoding wx.NullImage.AlphaBuffer

Member Avatar
0
7
Member Avatar

Anyone know of a way to tell the difference between an inherited class method and a individually defined one? ie: [CODE=python]class test(str): def unique(self): pass x = test() # how to test for difference between x.unique # and x.lower[/CODE]

Member Avatar
0
3
Member Avatar

I have a wx app that I would like to actively debug (even after it is compiled via py2exe). Is there a way to hook all methods(without having to manually add code to each one) and have it print their names' as they execute. I've looked into both the "inspect" and "pdb" modules and have a very limited understanding of both. Second question, is it possible to change a functions code "on the fly." ie afunction.func_code.co_code = "some compiled code". I'm just not sure how to compile the source. -Thx

Member Avatar
0
24
Member Avatar

This is my first experiment with sockets. Its kinda like the beginings of a VNC app. The basic gist is that one file on computer "A" takes a screenshot of the computer screen and sends it to computer "B" where another file accepts the connection and receives the data. Computer "B" then takes the image data and, using wxpython, displays the image refreshing the picture whenever a new image is received. My goal is to make the images on computer "B" to look like a low frame rate video (without the annoying white flash that occurs every refresh). I'll also …

Member Avatar
0
5
Member Avatar

Anyone know the developers? Anyone else waiting for 3.x support? This is the only thing keeping me from upgrading to python 3.1 ....

Member Avatar
0
6
Member Avatar

Here's my problem. I wx application that works great until I close it (leaving the idle editing session open) and then restart it. Then parts of the program see variables that should be things like 'wx.panel' as PyDeadObj .... Once I restart the idle session and re-run the program it works fine. I've tried reload(wx), I've tried deleting all wx variables from sys.modules ... Any more ideas?

Member Avatar
0
6
Member Avatar

I have a Syncing program that, while idle, crawls through the sub-directories of the sources and destinations saved to a 'sync profile'. It starts a new thread and walks the directories calculating the divergence between the sources and directories. I want this feature to have little impact on computer performance and be done quietly in the background. Currently to 'throttle back' CPU usage I have crudely implemented timer delays. Do the pros have a more efficient way to accomplish this? -Thanks

Member Avatar
0
7
Member Avatar

What is the consensus on the best way reference module level variables? I have a wx app that has grown too large, so I started to do some housekeeping. I'm trying to move several functions outside of the main module while still being able to reference the main variables.. The program works if I include [CODE=PYTHON]from __main__ import *[/CODE] at the top of the child modules, however it only works once. If I run the script without completely closing all python windows it raises [CODE=PYTHON]Traceback (most recent call last): File "C:\Python25\Lib\roster\roster_main.pyw", line 427, in Login Conform.Run() File "C:\Python25\Lib\roster\Conform.py", line 197, …

Member Avatar
-1
4
Member Avatar

My app works fine when its a .py file, however as soon as I compile it with py2exe 0.6.9 I get LookupErrors when using the email MIME library. I tried including the "packages": ["encodings"] option in py2exe but to no avail. I'll post the relevant code and traceback. (note: not an original script) EMAILER: [CODE]# -*- coding: utf-8 -*- from os.path import exists, basename import smtplib import mimetypes ##from email import * from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email.mime.text import MIMEText from email.mime.audio import MIMEAudio from email.mime.image import MIMEImage from email.encoders import encode_base64 def sendMail(gmailUser, gmailPassword, recipient, …

Member Avatar
0
2

The End.