4,305 Posted Topics

Member Avatar for Blujacker

You have to use the wx.BitmapButton(). there is an example in the DaniWeb snippets: [url]http://www.daniweb.com/code/snippet508.html[/url]

Member Avatar for vegaseat
0
109
Member Avatar for pythonguy

Generally you tell the dialog which files you want to display ... [code] dlg = wx.FileDialog(self, "Open a file") dlg.SetStyle(wx.OPEN) wildcard = "Python files (.py)|*.py|" \ "PythonW files (.pyw)|*.pyw|" \ "All files (*.*)|*.*" dlg.SetWildcard(wildcard) [/code]

Member Avatar for vegaseat
0
258
Member Avatar for shanenin

Great that you figured it out. I checked the win api help, and the only thing I came up with was a possible problem with the win api NULL and Python's None. It looks like there is no problem there! Nice to see you still active with Python!

Member Avatar for vegaseat
0
452
Member Avatar for Ene Uran

Since hexadecimal numbers are really strings representing a numeric value, you best convert these strings to a denary (base 10) number, do the mathematical operation and change the result back to the hexadecimal. Here is an example ... [code]def add_hex2(hex1, hex2): """add two hexadecimal string values and return as such""" …

Member Avatar for vegaseat
0
189
Member Avatar for Blujacker

Take a look at: [url]http://www.daniweb.com/code/snippet435.html[/url] This example uses wxPython. Another option is mentioned in the DaniWeb Python Tutorials under Multimedia.

Member Avatar for bumsfeld
0
678
Member Avatar for hotteaboi

The Python snippet at: [url]http://www.daniweb.com/code/snippet452.html[/url] contains a fair number of sorting algorithms, all geared to sort a list of integers. Pick one. You can also pick Python's built in ultrafast sort called sorted(). For a good example of sorted() look at: [url]http://www.daniweb.com/code/snippet506.html[/url]

Member Avatar for Dani
0
177
Member Avatar for a1eio
Member Avatar for Matt Tacular

Here is an example ... [code=python]# save this code as dec2bin.py so you can access the function decimal2binary() # in other Python programs def decimal2binary(n): '''convert decimal (base 10) integer n to binary (base 2) string bStr''' bStr = '' if n < 0: raise ValueError, "must be a positive" …

Member Avatar for a1eio
0
198
Member Avatar for vegaseat

Dani, I just put up a tutorial about "Python and Multimedia" [url]http://www.daniweb.com/tutorials/tutorial47392.html[/url] I need to add just a small paragraph at the end, explaining how to play movies. Multimedia is a little incomplete without that. I don't seem to have editing privileges.

Member Avatar for vegaseat
0
105
Member Avatar for katharnakh

If your spreadsheet writes out a CSV file, then you are in luck! A CSV file is basically a text file that contains each row in a line, with the cell Values Separated by Commas (hence CSV). Now you can use readlines() to generate a list of lines for processing. …

Member Avatar for vegaseat
0
201
Member Avatar for Blujacker

I would simply use lambda to extent the arguments passed to your callback function. I combined your code with an example I had ... [code=python]# display which widget was clicked from Tkinter import * root = Tk() root.title('Click on ovals') canvas1 = Canvas() canvas1.pack() def func1(event, widget_name): print widget_name # …

Member Avatar for bumsfeld
0
326
Member Avatar for skanker

The proper installation sequence is this way: 1) install the Python version for your operating system 2) install wxPython for your version of Python and OS

Member Avatar for vegaseat
0
147
Member Avatar for girish_sahani

In the absence of additional details, maybe our friend wants this result ... [php]def genC(featureList): prunedK = [] for i in range(0,len(featureList)): for k in range(0,len(featureList)): #print i, k if i != k: colocn = featureList[i] + featureList[k] prunedK.append(colocn) return prunedK print genC(['a','b','c','d']) """ result = ['ab', 'ac', 'ad', 'ba', …

Member Avatar for girish_sahani
0
73
Member Avatar for rubiton

The only tutorial I have seen is this one: [url]http://www.analysisandsolutions.com/code/mybasic[/url]

Member Avatar for rubiton
0
171
Member Avatar for girish_sahani

You want 'abc' to generate a list [['a','bc'],['bc','a'],['c','ab'],['ab','c'],['b','ac'],['ac','b']], right? The way your rules are set up you would never generate a 'ac' or 'ab' element. You got to work on that.

Member Avatar for girish_sahani
0
211
Member Avatar for ber

There has to be some association between those two files. Don't keep us in suspense.

Member Avatar for vegaseat
0
97
Member Avatar for Confucius

Here is another example how to do this, as suggested by cscgal ... [php]# save this code as endless.py password = raw_input("I am running almost endlessly unless you enter the secret password: ") if 'q' in password: raise SystemExit, "I am quitting now ..." execfile("endless.py") [/php] Notice how the ultimate …

Member Avatar for Confucius
0
105
Member Avatar for Ene Uran

Here is an example what the leading _ in a variable name is used for. It will keep a variable private in a module you write. Let's say you write a module ... [php]# save this simple code as mod_k.py k = "use me, use me!" _k = "I am …

Member Avatar for vegaseat
0
309
Member Avatar for Ene Uran

As far as I know, Python does not have an official static variable, but you can easily mimic one ... [code=python]# a mutable object like a list element as default argument # will act like a static variable since its address is fixed def static_num2(list1=[0]): list1[0] += 1 return list1[0] …

Member Avatar for vegaseat
0
148
Member Avatar for Blujacker

Are you mixing MS Visual C with Python? The error message does not look like a typical Python traceback error, it must be a MS problem.

Member Avatar for Blujacker
0
124
Member Avatar for warpeace2006

If you listen to Fox News with the rest of the morons, then the war in Iraq is "Mission (just about) Accomplished".

Member Avatar for server_crash
0
633
Member Avatar for madloch

You got to make sure that the statements that belong to the while loop (after the colon) are blocked by indentation. The print statement is not part of the loop! Look at the code carefully: [code]print "This program calculates how long it takes for an investment to double in size." …

Member Avatar for madloch
0
3K
Member Avatar for Aenima

I am using dev-c++ 4.9.9.1 and your last code works just fine (Windows XP). I think the version should not make any difference, that is only an update of the IDE. Are you using g++ as the compiler? I added a few test lines to your code ... [code]#include <iostream> …

Member Avatar for Aenima
0
264
Member Avatar for Ene Uran

You are dealing with date objects so it is best to use module datetime ... [code=python]import datetime # pick a year year = 2006 # create date objects begin_year = datetime.date(year, 1, 1) end_year = datetime.date(year, 12, 31) one_day = datetime.timedelta(days=1) print "These are all the dates of %d:" % …

Member Avatar for bumsfeld
0
5K
Member Avatar for rajashreeshinde

Python allows you to add documentation strings to a class, module or method and access it later ... [php]# a look at the Python documentation string # you can just use single quotes for a one liner import math def getDistance(x1, y1, x2, y2): """ getDistance(x1, y1, x2, y2) returns …

Member Avatar for rajashreeshinde
0
379
Member Avatar for Kiba Ookami

Dev C++ is just a nice free IDE that happens to use public domain compilers like g++ and gcc. Rumors about its death are a little premature, and are most likely spread by commercial interests, so you spend your money on their buggy compilers. My preferred book is "Standard C++ …

Member Avatar for vegaseat
0
139
Member Avatar for whoru

Looks to me like you have to append more names and scores to your player_score list before you use cPickle. The module cPickle just dumps and loads complete objects, it does not append the present object file. There is no need to import shelve, since you are not using it.

Member Avatar for G-Do
0
249
Member Avatar for Ene Uran

I have looked up some of the wxPython event handlers I have used over time. You are right there are different versions, some are outdated, some are personal preference. I prefer the version used by button4 or the mouse clicks on the parent frame ... [php]# checking different versions of …

Member Avatar for Ene Uran
0
380
Member Avatar for EriCartman13

Some of the answers are contained in the thread called "Starting Python" just above this thread. If you run your program from the IDE editor than you should see the result in the output window. In Windows, if you double click on the saved .py file, then python.exe gets invoked …

Member Avatar for EriCartman13
0
208
Member Avatar for default

Could you give us a code sample of what you have done so far, it might get some MatLab experts interested.

Member Avatar for b4codes
0
115
Member Avatar for potential

clrscr() is a presumptuous Borland fetish. Not every user of your program wants it!!! In Dev C++ you can use system("CLS") to do the trick, the old DOS command. Include the stdlib.h for the system() function. By the way, Dev C++ is a very nice IDE for a set of …

Member Avatar for Dave Sinkula
0
2K
Member Avatar for Confucius

[QUOTE=Confucius]Ok that works fine, but what is wrong with this program that I just made, it looks like it should work, but it doesn't. [code] a=input('Do you want to convert Fahrenheit, Celsius, or Kelvin? ') if a=Fahrenheit: f=input('Please enter a Fahrenheit value: ') b=input('Do you want to convert to Celsius …

Member Avatar for Ene Uran
0
310
Member Avatar for swapnamishra
Member Avatar for pythonguy

Bumsfeld is correct, the easiest way to communicate to a module is with a shared file. If your variable is the name for an object like a list, then you best use pickle to save and retrieve the whole object. To find out the folder where your module is located …

Member Avatar for pythonguy
0
139
Member Avatar for Avner .H.

Using Dev-C++ or Python with Windows, I found GTK one of the more frustrating GUI libraries, but it may work better under Linux. Just my limited opinion.

Member Avatar for JoeM
0
180
Member Avatar for G.Host

Python for the Apple MAC, give these sites a try: [url]http://undefined.org/python/[/url] also [url]http://www.pythonmac.org/[/url] more stuff in case of problems [url]http://wxpython.org/download.php#binaries[/url] [url]http://wiki.wxpython.org/index.cgi/wxPythonOSX%20Issues[/url] Sorry, I don't have an Apple computer.

Member Avatar for G.Host
0
156
Member Avatar for JoeM

My experience with pyGTK, I can not get it to work with Windows XP. The Linux folks have no problems. Before you go completely nuts with an unstable product, I would recommend switching to the wxPython GUI. Just my opinion!

Member Avatar for vegaseat
0
305
Member Avatar for bucodi

Andrea Gavana has created quite a few extensions to wxPython widgets in PyAUI, see: [url]http://www.daniweb.com/techtalkforums/thread40355.html[/url]

Member Avatar for bucodi
0
120
Member Avatar for swapnamishra

I would use self to carry the variable name within the class. Also by convention class names start with an uppercase letter. [code]class A: name = "swapna" def show(self): print self.name s = A() s.show() [/code]

Member Avatar for bumsfeld
0
151
Member Avatar for bhupendra
Member Avatar for bhupendra
0
178
Member Avatar for Vedavyas

A Windows GUI program can handle this best. I have attached a sample created by BCX and modified for PellesC, all free downloads from the net.

Member Avatar for Vathanak
0
824
Member Avatar for sharma_vivek82
Member Avatar for greatbear

[QUOTE]... why do you choose Python to substitute for java , C++ or visual Basic ?[/QUOTE] Developing an application is simply much faster. The code is easier to maintain by yourself and other people. Like Java, Python has JIT compilers and speed optimized modules available for higher speed applications. For …

Member Avatar for greatbear
0
98
Member Avatar for sharma_vivek82
Member Avatar for gYbU

I imagine you used the smtplib module and its functions to send e-mail. Well, you use the poplib module and its functions to view and delete e-mail. Use help('poplib') to get details. A rather crummy example is at [url]http://docs.python.org/lib/pop3-example.html[/url]

Member Avatar for vegaseat
0
598
Member Avatar for Blujacker

wxPython also offers HtmlEasyPrinting, for an example go to this web site: [url]http://wiki.wxpython.org/index.cgi/Printing[/url]

Member Avatar for vegaseat
0
99
Member Avatar for Ene Uran

Bumsfeld, this is an interesting application of the lambda function! You can even make it simpler using tuple indexing directly ... [code=python]for k in range(100): # selects index 0 (False) or 1 (True) of tuple depending on == compare select_tab_or_newline = ('\t', '\n')[k % 10 == 9] print "%3d%s" % …

Member Avatar for Ene Uran
0
118
Member Avatar for butterflyTee

I don't have the graphics module, but I tested your logic and found it faulty. Here is my test code: [PHP]age = int(raw_input("years of age: ")) citizenship = int(raw_input("years citizen: ")) # age 25 to less than 30 if 25 <= age < 30: if citizenship >= 7: print 'Eligible …

Member Avatar for butterflyTee
0
115
Member Avatar for butterflyTee

You are almost there, please try to understand the logic here ... [php]def calc_discount(cost): if cost > 1000.00: discount = cost * 0.1 # 10% return discount elif cost > 500.00: discount = cost * 0.05 # 5% return discount else: # no discount return 0.0 [/php] Once you know …

Member Avatar for butterflyTee
0
111
Member Avatar for a1eio

There is a thing like that in Tkinter, observe ... [code=python]# to create additional windows, you can use Toplevel() # when you quit the root window the child window also quits from Tkinter import * # create root window root = Tk() root.title('root win') # create child window top = …

Member Avatar for a1eio
0
22K

The End.