4,305 Posted Topics

Member Avatar for soUPERMan

This will allow you to test your module ... [code]# Function that recieves number of characters and calculate cost # of advertising, save module as costAd.py (case sensitive) def costAd(numChar): if numChar >= 15: cost = 35.00 else: cost = 35.00 + ((numChar - 15) * 3.55) return cost # …

Member Avatar for soUPERMan
0
178
Member Avatar for wtzolt
Member Avatar for sindhujavenkat

This may give you a hint ... [code]# a statusbar is an information line at the bottom of a frame # set and clear the info import wx class MyFrame(wx.Frame): def __init__(self, parent, mytitle, mysize): wx.Frame.__init__(self, parent, -1, mytitle, size=mysize) # fill the top part with a panel panel = …

Member Avatar for vegaseat
0
89
Member Avatar for baki100

Here you go ... [code]# a wxPython general frame template import wx class MyFrame(wx.Frame): def __init__(self, parent, mytitle, mysize): wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle, size=mysize) self.SetBackgroundColour("red") # create an input widget # # bind mouse or key event to an action # # create an output widget # def onAction(self, event): …

Member Avatar for baki100
0
274
Member Avatar for cnuzzo

Can you boil that down to just the minimum code required to do what you want to do?

Member Avatar for cnuzzo
0
1K
Member Avatar for herrschteiner

Since hex numbers '87' and 'c4' are not even in your charset, it could take you a very long time to match. :) You could use this little test program ... [code]import random # search for this upper case HexValue string: # use hex digit pairs that are in the …

Member Avatar for herrschteiner
0
222
Member Avatar for MichelleCrews

I would approach it this way ... [code]def is_magic(n): """check if n is a perfect (magic) number""" acc = 0 for i in range(1, n): if (n % i == 0): factor = i # these 2 lines could be acc += i acc += factor if (acc == n): …

Member Avatar for MichelleCrews
-1
504
Member Avatar for elt6801
Member Avatar for elt6801
0
168
Member Avatar for LEEEEE

Writing windows programs in C/C++ can be a bear for even experienced programmers. I started out with the DEV C++ package and quickly switched to BCX. This is a basic to C/C++ translator that uses simple basic code and allows inline asm and C code. If you are familiar with …

Member Avatar for WaltP
0
214
Member Avatar for morgan505

Hint: If you [B]read[/B] your text file as one complete string (call it [B]text[/B]), then you can do a couple of split() operations ... [B]line_list = text.split('\n')[/B] [B]word_list = text.split()[/B] Now get the length of these lists ... [B]line_count = len(line_list)[/B] [B]word_count = len(word_list)[/B] You are splitting the text string …

Member Avatar for vegaseat
0
116
Member Avatar for spiricn
Member Avatar for spiricn
0
174
Member Avatar for 1988asso

Adding a toolbar to a panel is somewhat tricky, but can be done. For an example see: [url]http://www.daniweb.com/forums/post1138860.html#post1138860[/url]

Member Avatar for vegaseat
0
117
Member Avatar for gridder

You could potentially do something like this ... [code]line = "10810 'AHANE 10' 110.00 1 0.00 0.00 1 1 1.0517 -4.091" rawlist = line.split("'") print rawlist # test number = rawlist.pop(0).strip() name = rawlist.pop(0).strip() numbers = rawlist.pop(0).strip() mylist = [number, name] for n in numbers.split(): mylist.append(n) print mylist [/code]

Member Avatar for gridder
0
124
Member Avatar for edy_sze

You can test this sort of thing with module timeit ... [code]import timeit stmt1 = "x = '0' + 'ff12'" print( "%s took %0.3f micro-seconds" % (stmt1, timeit.Timer(stmt1).timeit()) ) stmt2 = "x = ['ff12'].insert(0, '0')" print( "%s took %0.3f micro-seconds" % (stmt2, timeit.Timer(stmt2).timeit()) ) """my result --> x = '0' …

Member Avatar for edy_sze
0
137
Member Avatar for germ

What have you tried so far? Hint, you can read the file in one line at a time using a for loop. Each line will be a string that can be processed using your criteria.

Member Avatar for vegaseat
0
159
Member Avatar for bharatk

You got to let Python know where you want to create the Tkinter widgets. By default it's the MainWindow root. Change your code like this ... [code]from Tkinter import * class TopLevel3: def __init__(self): self.root2 = Toplevel() # lift root2 over MainWindow root1 self.root2.lift(aboveThis=mw.root1) self.canvas3 = Canvas(self.root2, width=400, height=200) self.canvas3.pack() …

Member Avatar for bharatk
0
118
Member Avatar for Purnima12

With some luck your department will publish a list of school holidays and then you can transfer it easily to a list of (month, day) tuples for the year, or the dictionary Gribouillis suggested.

Member Avatar for woooee
0
162
Member Avatar for Logi.

Something like this will work ... [code=python]import Tkinter def win1(): # this is the main/root window root = Tkinter.Tk() root.title("Window 1") startButton = Tkinter.Button(root, text="Start", command=win2) startButton.grid(row=9, column=7) leaveButton = Tkinter.Button(root, text="Quit", command=root.destroy) leaveButton.grid(row=1, column=1, sticky='nw') b1Var = Tkinter.StringVar() b2Var = Tkinter.StringVar() b1Var.set('b1') b2Var.set('b2') box1Label = Tkinter.Label(root,textvariable=b1Var,width=12) box1Label.grid(row=3, column=2) box2Label …

Member Avatar for bharatk
0
8K
Member Avatar for cwarn23
Member Avatar for vegaseat
-3
156
Member Avatar for RatulSaha

It's best to write yourself a little function ... [code]# working with deque (double ended que) # delete an item from a deque at given index from collections import deque def dq_delete(dq, del_ix): """delete a deque item at index del_ix""" dq2 = deque() for ix, item in enumerate(dq): if ix …

Member Avatar for vegaseat
0
147
Member Avatar for nimmyliji

This little code might give you a hint ... [code]# print out the third Fridays of each month in a given year import calendar year = 2010 print( "The third Friday of each month in %d:" % year ) for month in range(1, 13): k = 0 for day in …

Member Avatar for vegaseat
0
143
Member Avatar for lsy_19830908

I don't have BOA, but I quickly created a sample program using the wxGlade designer and the SPE editor. It shows you how to set up a tree ... [code]#!/usr/bin/env python # -*- coding: iso-8859-15 -*- # generated by wxGlade 0.6.2 on Fri Feb 19 05:43:46 2010 import wx # …

Member Avatar for vegaseat
0
458
Member Avatar for bharatk

I thought that looked familiar. Looks like [B]def img_zoom(self, image1):[/B] also receives an event from the menu click, so try [B]def img_zoom(self, image1, event):[/B] where event is simply a dummy.

Member Avatar for bharatk
0
383
Member Avatar for A_Dubbs

You can run this Python file after proper option modifications to package a wxPython program with py2exe ... [code]""" file = wx2exeZ.py Py2Exe (version 6.6 and higher) setup file for wxPython GUI programs. Creates an exe file and a library.zip file. It's easiest to save this wx2exeZ.py file into the …

Member Avatar for snippsat
0
752
Member Avatar for Kruptein

Text files use mode "r" and the contents are usually read until they reach the EOF marker (end of file). Non ASCII files can contain an EOF marker anywhere in the file.

Member Avatar for vegaseat
0
238
Member Avatar for gunbuster363

Just for the fun of Python ... [code]# using the Python local dictionary vars() # you can dump/save and load mystr_dict with module pickle def mystrings(): s1 = 'I ' s2 = 'like ' s3 = 'Python' # in this case vars() is local to this function return vars() mystr_dict …

Member Avatar for lrh9
0
107
Member Avatar for gunbuster363

You save your entire data with module pickle. Here is an example ... [code]# use module pickle to save/dump and load a dictionary object # or just about any other intact object # use binary file modes "wb" and "rb" to make it work with # Python2 and Python3 import …

Member Avatar for sahiti
0
104
Member Avatar for Robbert

I don't think you want to create a new label widget every time you click on the menu item. That would eventually tax your computers memory. I corrected your code to replace the text in the same label ... [code]import wx class MyFrame(wx.Frame): def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, …

Member Avatar for vegaseat
0
175
Member Avatar for Noliving

So you want to go through [B]a op b op c[/B] until the result matches your target. Where a, b, c are integers and op are the various operators. Right?

Member Avatar for lyndon enero
0
91
Member Avatar for Kruptein

Some goofy indentations in there. You are mixing tabs and spaces, a recipe for disaster! I recommend to stick with spaces!

Member Avatar for Stefano Mtangoo
0
276
Member Avatar for Kruptein

In line 127 [B]self.stilltext = StillText(DEDITOR(self), -1, "")[/B] creates a new instance of class DEDITOR, you want to use the instance created in __main__

Member Avatar for Kruptein
0
123
Member Avatar for Lolalola
Re: wmi

You also need to install the win32 extension module, free from: [url]http://sourceforge.net/projects/pywin32/files/[/url]

Member Avatar for Lolalola
0
165
Member Avatar for nimmyliji

Look at the module time The two time methods strptime() and strftime() are your friends.

Member Avatar for nimmyliji
0
45
Member Avatar for new programer
Member Avatar for vsagarmb
Member Avatar for sindhujavenkat

If you use an absolute layout, you can respond to a button click by moving the desired widgets to a new position.

Member Avatar for vegaseat
0
57
Member Avatar for kfancy

Like BearofNH pointed out in your other thread, the problem is in lines 18 and 19 [B]self.rank = str(self.rank) self.value = self.rank[/B] You are turning self.rank into a string and then assign it self.value. The solution would be to simple reverse the two lines ... [B]self.value = self.rank self.rank = …

Member Avatar for woooee
0
170
Member Avatar for bharatk

If you put the image on a canvas, you can delete it with something like canvas.delete(image)

Member Avatar for bharatk
0
1K
Member Avatar for Mushy-pea

Wealth created by speculation can evaporate quickly. The US government owns a huge amount of land and resources that it can use as a collateral.

Member Avatar for jbennet
0
287
Member Avatar for kfancy

There are quite a number of errors in your code. Check the remarks ending with '!!!!!!!!!!!' in the corrected code ... [code]import random class Card: def __init__(self, suit, rank, value): self.rank = rank self.suit = suit self.value= value if self.rank == 1: self.rank = "Ace" self.value = 11 elif self.rank …

Member Avatar for redyugi
0
178
Member Avatar for rehber344

[B]def continueof(rotator):[/B] is a function, not a class. You can't set it up like a class and use it like a class.

Member Avatar for vegaseat
0
117
Member Avatar for rlogan1

After line [B]data = s.recv(1024)[/B] put in a test print [B]print data[/B] What do you get?

Member Avatar for rlogan1
0
97
Member Avatar for Kruptein

Your code is a mess! The all important indentations are mixed up and you are still using tabs. My program editor cannot handle this. For instance tabs expand to 8 spaces in DaniWeb's code field and after a few of those gigantic indents I can't even stomach the looks of …

Member Avatar for Kruptein
0
175
Member Avatar for Narue

[B]sneekula:[/B] I know Snee is a science grad student. He likes the Cs, that is the C language, Computers, Church, Chemistry, Cooking and Cars. He seems to be light hearted, easy going, and on occasion will leave the Geek's Lounge to make a contribution to the Python forum.

Member Avatar for jonsca
2
512
Member Avatar for Stefano Mtangoo

I don't think PIL can do this. The XPixelMap format is a text based C array and you could probably take bitmap information and create this array and save it. Presumably there are C utilities around that create XPM files, you should be able to run those from within Python. …

Member Avatar for Stefano Mtangoo
0
849
Member Avatar for sindhujavenkat
Member Avatar for Hawkeye Python

In the mean time changing [B]saldo = f.readline()[/B] to [B]saldo = int(f.readline())[/B] will work

Member Avatar for snippsat
0
120
Member Avatar for Stubaan

You can test Gribouillis' clever code with something like this ... [code]# delete lines 0-51, 53-153, 155-255, 257-357 and so on in_list = list(range(1000)) out_list = [] save_line = 52 for ix, line in enumerate(in_list): if ix == save_line: out_list.append(line) save_line += 102 print(out_list) # [52, 154, 256, 358, 460, …

Member Avatar for Stefano Mtangoo
1
119
Member Avatar for vermont

Python checks in the working directory first, and if you save one of your own files with a module name, you don't get the proper module.

Member Avatar for vegaseat
0
1K
Member Avatar for vamsicoolman

The End.