4,305 Posted Topics
Re: You have to use the wx.BitmapButton(). there is an example in the DaniWeb snippets: [url]http://www.daniweb.com/code/snippet508.html[/url] | |
Re: 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] | |
Re: 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! | |
Re: 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""" … | |
Re: 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. | |
Re: 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] | |
Re: 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" … | |
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. | |
Re: 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. … | |
Re: 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 # … | |
Re: 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 | |
Re: 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', … | |
Re: The only tutorial I have seen is this one: [url]http://www.analysisandsolutions.com/code/mybasic[/url] | |
Re: 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. | |
Re: There has to be some association between those two files. Don't keep us in suspense. | |
Re: 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 … | |
Re: 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 … | |
Re: 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] … | |
Re: 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. | |
Re: If you listen to Fox News with the rest of the morons, then the war in Iraq is "Mission (just about) Accomplished". | |
Re: 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." … | |
Re: 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> … | |
Re: 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:" % … | |
Re: 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 … | |
Re: 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++ … | |
Re: 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. | |
Re: 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 … | |
Re: 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 … | |
Re: Could you give us a code sample of what you have done so far, it might get some MatLab experts interested. | |
Re: 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 … | |
Re: [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 … | |
Re: Look under shelve in Python help. | |
Re: 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 … | |
Re: 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. | |
Re: 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. | |
Re: 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! | |
Re: Andrea Gavana has created quite a few extensions to wxPython widgets in PyAUI, see: [url]http://www.daniweb.com/techtalkforums/thread40355.html[/url] | |
Re: 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] | |
Re: You got to explain that "model less dialog box" a little more. | |
Re: 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. | |
Re: Indent it correctly, download posix and give it a try. | |
Re: [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 … | |
Re: Once you indent it correctly it works just fine. | |
Re: 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] | |
Re: wxPython also offers HtmlEasyPrinting, for an example go to this web site: [url]http://wiki.wxpython.org/index.cgi/Printing[/url] | |
Re: 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" % … | |
Re: 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 … | |
Re: 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 … | |
Re: 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 = … |
The End.