4,305 Posted Topics

Member Avatar for lockettpots

Just for kicks, did you try: # -*- coding: iso-8859-15 -*- as the first line of your code?

Member Avatar for lockettpots
0
99
Member Avatar for seasou

I am not sure if there is a Python module out there that includes the .swf file format. However you can press your webbrowser into service ... [code=python]import webbrowser # html code to embed a .swf flash file player str1 = """ <html> <head> <title>Embedded SWF Player</title> </head> <body onLoad="resizeTo(560, …

Member Avatar for seasou
0
2K
Member Avatar for Tom Pilk

Tom, sorry couldn't do it in qbasic. Take a look at: [url]http://www.daniweb.com/code/snippet224.html[/url] This short code is written in a more modern basic dialect called BCX-basic which makes it easy to write Windows GUI programs.

Member Avatar for gummo
0
1K
Member Avatar for babutche

Two issues here, one is the use of code tags in your posting of code. The tags are particularly important with Python code, since they preserve the indentations. Without those indentation much of the code becomes unreadable, as the statement blocks can not clearly be identified. The second issue, you …

Member Avatar for babutche
0
182
Member Avatar for jrcagle

From what I understand the limit is the memory on your computer, not Python. How many megs can the text in 'War and Peace' take up?

Member Avatar for Ene Uran
0
91
Member Avatar for babutche

At first look, when you compare two items use == in your if statements ... [code=python] def addLetterGrade(self, Letter, credits): self.hours = credits for ch in Letter: print ord(ch) self.qpoints = credits*Letter if grade_str == "A": # use == !!!!!!!!!!!! grade_str = 4.0 elif grade_str == "B": grade_str = 3.0 …

Member Avatar for babutche
0
202
Member Avatar for Matt Tacular

I hope this is what you had in mind ... [code=python]# goal: make two lists of 4 countries from the initial 8 country list # no list gets the same country as another list, and no duplicate countries in one list import random availableCountries = [0, 1, 2, 3, 4, …

Member Avatar for Matt Tacular
0
113
Member Avatar for sneekula

As an example I pulled the basics out of the bus ticket program. Here is the original global variable version ... [code=python]class Main(object): def __init__(self, master): self.master = master self.display() def display(self): global p global pp p = 2.20 pp = 0.50 # variables p and pp are passed as …

Member Avatar for vegaseat
0
19K
Member Avatar for chupacabra

Not all of us are familiar with the mySQLdb module. Can you give us a little more info?

Member Avatar for locosway
0
137
Member Avatar for mruane

What does the module 'helpers' look like? I don't seem to have it in my normal PyGame installation.

Member Avatar for vegaseat
0
632
Member Avatar for mattyd
Member Avatar for sneekula

[QUOTE=sneekula;287337]As you can see, I am playing around with the Tkinter GUI toolkit. How can I keep a number of widgets fixed in a location even when the user expands the window?[/QUOTE]Well, this is one way to accomplish this ... [code=python]# let user resize the Tkinter window, but do not …

Member Avatar for sneekula
0
195
Member Avatar for sneekula

Here is one way you could sort your table by column. Also note that I put your pretty print into a function ... [code=python]# table of chemicals in stockroom as list of lists # order --> stock number, chemical name, quantity (grams) from operator import itemgetter def sort_table(table, column_num): """ …

Member Avatar for sneekula
0
155
Member Avatar for linux

You could write a GUI toolkit with Python, but you have to understand that the real low level stuff would have to written in a low level language like C or Assembly. Python is a good glue language and bringing in C modules would be hospitable. For your last question, …

Member Avatar for vegaseat
0
209
Member Avatar for sneekula

This should do it ... [code=python]# make a Tkinter window that is not resizable # also disables the maximize button from Tkinter import * root = Tk() # root.resizable(0, 0) or in detail ... root.resizable(width=FALSE, height=FALSE) # your code here ..... root.mainloop() [/code]

Member Avatar for sneekula
0
162
Member Avatar for Haze

Sounds like you want to do a simple swap crypting, something like this? [code=python]# simple crypt using a swap of 2 adjoining characters def swap_crypt(str1): """ this function will encrypt/decrypt a string """ # change string to a mutable list of characters list1 = list(str1) # iterate the list with …

Member Avatar for jrcagle
0
2K
Member Avatar for mattyd

Thus spoke the Lord: "Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. …

Member Avatar for jrcagle
0
244
Member Avatar for shr2408

This should help you ... [code=python]# bind and show a key event with Tkinter from Tkinter import * root = Tk() prompt = ' Press any key ' label1 = Label(root, text=prompt, width=len(prompt)) label1.pack() def key(event): if event.char == event.keysym: msg = 'Normal Key %r' % event.char elif len(event.char) == …

Member Avatar for shr2408
0
1K
Member Avatar for vegaseat

sharky_machine Offline Posting Whiz in Training Join Date: Oct 2006 Location: New York City Posts: 253 Rep Power: Re: Starting Python Today, 1:41 pm | Add to sharky_machine's Reputation | Add Infraction | Flag Bad Post | IP | #86 -------------------------------------------------------------------------------- Vegaseat: I have been reviewing this code you had …

Member Avatar for mattyd
0
306
Member Avatar for freesoft_2000

Okay Richard, April 1st has passed, when are you going to let the cat out of the bag?

Member Avatar for freesoft_2000
0
596
Member Avatar for mattyd

Dictionaries are ultrafast lookup 'machines', also used by Python internally. In order to do the fast lookups the keys are hashed (digitized) and put into the dictionary in that order. The order is by hashed key, there is no sequential index lookup like in a list.

Member Avatar for jrcagle
0
81
Member Avatar for Matt Tacular

This might be easier to understand ... [code=python]# test if list is empty list1 = [] list2 = [7] if len(list1) > 0: print "list1 is not empty" else: print "list1 is empty" if len(list2) > 0: print "list2 is not empty" else: print "list2 is empty" """ output = …

Member Avatar for Matt Tacular
0
82
Member Avatar for cambrian

I know this code all too well! [url]http://www.daniweb.com/code/snippet578.html[/url] Why did you add these two lines? [CODE]import sys sys.frozen = 1[/CODE]

Member Avatar for vegaseat
0
1K
Member Avatar for Matt Tacular

Good thing you found the problem! There is also a line [INLINECODE]global newAttackTo[/INLINECODE] that should not be there. Another thing that sticks out, you may have done that already, you need to do some hand holding for the user, giving an idea what range of numbers to input.

Member Avatar for Matt Tacular
0
209
Member Avatar for danizzil14

There is a small Python utility program showing how to generate .exe files from your Python code at: [url]http://www.daniweb.com/code/snippet499.html[/url] You can download Py2Exe for your version of Python free from: [url]http://www.py2exe.org/[/url]

Member Avatar for 7even
0
108
Member Avatar for sneekula

This may be more difficult than you think. The files in the list need to have a full path name, see if the following list will do ... [code=python]# example walking a directory/folder # create a list of all files with a given extension in # a given the directory …

Member Avatar for Ene Uran
0
3K
Member Avatar for mattyd

Depends where you have to learn the most. If you are familiar with the game logic and new to GUI coding, test out the GUI with simple examples that mimic your game. Once that works, flesh out your GUI code with the game logic.

Member Avatar for mattyd
0
137
Member Avatar for shappell
Member Avatar for mattyd

Take a look at: [url]http://www.daniweb.com/techtalkforums/post257347-78.html[/url] that Tkinter cardgame example uses a card_name:image_object dictionary.

Member Avatar for vegaseat
0
130
Member Avatar for danizzil14

None of the traditional GUI toolkits for Python require you to use object oriented programming ('OOP has class'), but it makes more complex programs easier to write and maintain. For some additional info see: [url]http://www.daniweb.com/techtalkforums/thread61194.html[/url]

Member Avatar for Ene Uran
0
219
Member Avatar for dunderhead

I don't have Fedora, so I can't see the effect, but check if Refresh() or Update() will help ... [code=python] ### uncomment the following 2 lines of code and ### the popup menu will not appear on fc5 if dlg.ShowModal() == wx.ID_OK: # do something thisresult = "a file was …

Member Avatar for vegaseat
0
458
Member Avatar for jrcagle

The answer is in: [url]http://www.daniweb.com/techtalkforums/post139280-20.html[/url] When you import a module then Python will look first for the .pyc compiled module. You might have to force your changed module to update the .pyc file. So, after saving your updated 'my_asn.py' file, run this little utility program ... [code=python]import py_compile py_compile.compile("my_asn.py") # …

Member Avatar for vegaseat
0
118
Member Avatar for sneekula

I had to fiddle with this for a while to get it to go. The scrollbar is a little hairy with Tkinter. Here is an example how to do this ... [code=python]# loading a Tkinter listbox with data and selecting a data line from Tkinter import * def get_list(event): """ …

Member Avatar for vegaseat
0
2K
Member Avatar for chubbywubba

If you are running Windows, check this code snippet: [url]http://www.daniweb.com/code/snippet83.html[/url]

Member Avatar for vegaseat
0
71
Member Avatar for Sin-da-cat

[QUOTE=Sin-da-cat;278380]All the words have one CAP in the beginning and then all lowercase so I don't see how it matters. It's not like there are gonna be caps in the middle of words that will interrupt the comparing. EDIT: No, wait...some don't. But that's not the basic issue here.[/QUOTE] Sin-da-cat, …

Member Avatar for vegaseat
0
386
Member Avatar for 7even

Are you talking about something like this ... [code=python]# example of wx.TreeCtrl() import wx class TestFrame(wx.Frame): def __init__(self): wx.Frame.__init__(self, None, title="tree example", size=(300,130)) self.cb1 = wx.CheckBox(self, -1, "test1", pos=(280,10)) self.cb1.Hide() self.tree = wx.TreeCtrl(self, size=(280,100)) root = self.tree.AddRoot("Example") items = ["test1", "test2", "test3",] self.AddTreeNodes(root, items) self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.OnItemExpanded, self.tree) self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.OnItemCollapsed, self.tree) …

Member Avatar for vegaseat
0
628
Member Avatar for Firestone

Follow your values with a couple of test printf() statements to help you find the errors! Also use [INLINECODE]scanf("%d", &av[y]);[/INLINECODE] Your function avg() should really calculate and return a double.

Member Avatar for Ancient Dragon
0
108
Member Avatar for sneekula

To play sound on a Tkinter application you can use the module winsound. This module however works only on Windows computers. If you want to be more cross platform you can just combine Tkinter and PyGame ... [code=python]# play a sound on key press from Tkinter import * from pygame …

Member Avatar for sneekula
0
5K
Member Avatar for MarkWalker84

You are right, Title_Panel is not recognized as a wxPython object. For some odd reason my brain is comatose today. If you want other folks to help you with your code, I encourage you to follow the recommended Python naming convention. Class names start with a capital letter, something like …

Member Avatar for vegaseat
0
96
Member Avatar for goldeagle2005

Thanks for the fine wine goldeagle2005! Didn't have a glass small enough to put it in!

Member Avatar for ~s.o.s~
1
197
Member Avatar for sneekula

Python Byte Code is actually machine code. To be specific, it is machine code for the Python Virtual Machine within the interpreter. Java does something quite similar for the Java Virtual Machine (JVM). Since the machine code is not written for a specific CPU Python like Java becomes much more …

Member Avatar for vegaseat
0
148
Member Avatar for sneekula

Even if you don't forget to put the counter into the 'while loop' you can still make an error ... [php]# now you have an accidental endless loop k = 0 while k < 10: # the k counter k += 1 print k # more code here # now …

Member Avatar for bumsfeld
0
131
Member Avatar for sneekula

As a beginner, start working with Tkinter to get a feeling what GUI programming is all about. Tkinter is already present in the normal Python installation. If you need fancier widgets later, download wxPython and experiment with that. PyGTK/GTK works best with Linux, the Windows version needs a lot of …

Member Avatar for vegaseat
0
435
Member Avatar for MarkWalker84

Looks like you are working within a class and have to be more religious about using 'self.' to instance the items. If you give me your whole code, I will be able to help. Otherwise it is just guess work! Take a look at: [url]http://www.daniweb.com/code/snippet403.html[/url]

Member Avatar for vegaseat
0
334
Member Avatar for sneekula

The "for loop" loops (iterates) through the items of a sequence (string, list, tuple, dictionary, set ...). The "while loop" loops until a condition is met. Though the two loops are different beasts, they can overlap in functionallity. You can break out of either loop on a conditional statement. If …

Member Avatar for fireworks-style
0
189
Member Avatar for Mouche

Wonderful game, could be the start of a hangman game. I have 2 suggestions. Make all the input lower case with lower() and let the user know if the letter guess was acceptable by updating the masked_word each time, easily done with a function ... [code=python]# word guess game by …

Member Avatar for vegaseat
0
10K
Member Avatar for Mouche

Just to make things clear, you want to use Newton's method to solve a system of 2 nonlinear equations. Is that what you have in mind? Your real problem is to parse the user input to something that Python can work with. So 3x^2 becomes 3*(x**2). This could get pretty …

Member Avatar for Mouche
0
211
Member Avatar for Mouche

Just for form, import your modules, do define your classes and functions, then write the rest of the code lines. Be judicious with self, it is to be used in classes and their methods. If you use it outside of classes it will confuse you later!

Member Avatar for Mouche
0
193
Member Avatar for ~s.o.s~

If you want an elegant modern language go with Python. It is the glue for all your C/C++ code. The folks at Google use it extensively and are active supporters of Python! Edit: Lisp is interesting, but old. It has been around 'forever'! Lua is from South of the border …

Member Avatar for ~s.o.s~
0
402
Member Avatar for mattyd

A nice style guide for C/C++ code: [url]http://www.gidnetwork.com/b-38.html[/url]

Member Avatar for vegaseat
0
323

The End.