904 Posted Topics

Member Avatar for Jusa

You need to set gVar global in function setVar(), so it will be visible for function getVr(): [code=python]gVar = None def getVar(): return gVar def setVar(val): global gVar gVar = val [/code]

Member Avatar for Jusa
0
92
Member Avatar for Jusa
Member Avatar for Jusa
0
2K
Member Avatar for Blujacker

I added some needed lines to your code, now it works. Somehow you have to refresh your drawing as you scroll: [code=python]import wx class Canvas(wx.ScrolledWindow): def __init__(self,parent): self.okno=parent self.radic = wx.FlexGridSizer(3,2,0,0) self.canvas = wx.ScrolledWindow(self.okno, -1) # EnableScrolling(bool x_scrolling, bool y_scrolling) self.canvas.EnableScrolling(True, True) # SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, int noUnitsX, # …

Member Avatar for Blujacker
0
1K
Member Avatar for aot
Member Avatar for jrcagle
0
68
Member Avatar for aot

Must be something peculiar to the Mac OS, this code works fine on Windows: [code=python]import Tkinter as tk def change(event): root.title(str(v_red.get())) root = tk.Tk() # width x height + x_offset + y_offset (no spaces!) root.geometry("%dx%d+%d+%d" % (150, 120, 0, 0)) v_red = tk.IntVar() red = tk.Scale(root, label="Red", variable=v_red, from_=0, to=255) …

Member Avatar for bumsfeld
0
80
Member Avatar for a1eio

Keyword variable image=object needs an object not a function call. You need to use image1=PhotoImage(file="image.gif") and then self.Button = Button(self, image=image1)

Member Avatar for a1eio
0
156
Member Avatar for Jishnu

Graphics.h? Let me guess, must be from the old Tubo C compiler (16bit), good luck to find anyone that uses this old bird!

Member Avatar for ~s.o.s~
0
153
Member Avatar for aot

Here is the code for a title-free Tkinter window. [php]import Tkinter as tk root = tk.Tk() # eliminate the titlebar root.overrideredirect(1) # your code here ... root.mainloop() [/php]You have to exit the program somehow and could create one exit/quit button that needs secret password to quit.

Member Avatar for scru
0
17K
Member Avatar for mattyd

Sure Python has multidimensional arrays, they are called lists of lists or tuples of tuples etc. [code=python]mlist1 = [ [7, 12, 23], [22, 31, 9], [4, 17, 31]] print mlist1 # [[7, 12, 23], [22, 31, 9], [4, 17, 31]] # show list_item at index 1 print mlist1[1] # [22, …

Member Avatar for jrcagle
0
441
Member Avatar for alba07

This uses popen4(), but I think its similar: [code=python]# run an external program (cmd) and retrieve its output: import os cmd = "ls" fin, fout = os.popen4(cmd) result = fout.read() print result [/code]

Member Avatar for alba07
0
84
Member Avatar for R.S.Chourasia

RSC, thanks for the reference. Working with SWIG can be interesting, but their seems to be lots of pitfalls to avoid!

Member Avatar for bumsfeld
0
127
Member Avatar for Acolyte

For button1 use : [INLINECODE]self.myboxsizer.Add(self.button1,0,wx.EXPAND|wx.ALL,30)[/INLINECODE] I works on Windows OS, Linux may behave differently.

Member Avatar for Acolyte
0
89
Member Avatar for chris99

You have really butchered the original example code! I would suggest to reload the original code and it will work fine!

Member Avatar for bumsfeld
0
284
Member Avatar for muddpigeon

Here is way to do it: [php]def check_pin(pin): """check if pin number pin is between 1000 and 9000""" if 1000 <= pin <= 9000: return True return False pin = int(raw_input("Enter pin number (between 1000 and 9000): ")) print check_pin(pin) [/php]

Member Avatar for muddpigeon
0
84
Member Avatar for GreenDay2001

[QUOTE=Ancient Dragon;315223]I don't know what window() does.[/QUOTE]There is Windows API function, see thread: [url]http://www.daniweb.com/code/snippet217.html[/url]

Member Avatar for GreenDay2001
0
486
Member Avatar for scru

[QUOTE=Ancient Dragon;315137]I don't know about phthon but I know that can be done in C or C++ using sockets. Computers attached to a LAN (Local Area Network) do not require internet service provider but others do.[/QUOTE]Here is your answer! Use C++! You may want to repost your request in the …

Member Avatar for scru
0
112
Member Avatar for AussieCannon

[QUOTE=vegaseat;311399] Looks like someone at the office has been messing with the code field again, sorry! Copy and pasting code is a mess now!!!!!!!!!!![/QUOTE]Gee, vegaseat you are old and blind. This is supposed to be improvement. See the little line 'Toggle Plain Text' just below the code, click on it, …

Member Avatar for vegaseat
0
443
Member Avatar for defience

Right now the main thing wrong are all the missing indentation that Python uses to block code. It would be nice to know what 'wordlist.txt' looks like.

Member Avatar for defience
0
127
Member Avatar for vivekr

I think you can replace javascript with python code, but your webserver has to be python enabled.

Member Avatar for bumsfeld
0
69
Member Avatar for chris99

Just in case others may wonder, you put the event loop mainloop() in the wrong place: [code]from Tkinter import * class Main: def __init__(self, master): self.master = master self.master.title('Role Playing Form V1.0') self.master.geometry('300x250+350+450') #self.master.mainloop() #!!!!!!!!!! self.cmdCreate = Button(self.master, text='Create Character', command=self.create) self.cmdCreate.grid(row=0) def create(self): pass root = Tk() main=Main(root) # …

Member Avatar for bumsfeld
0
140
Member Avatar for Jergosh
Member Avatar for woooee
0
98
Member Avatar for bumsfeld

Decided to start my own thread rather than hijack thread "Sorting" I followed ghostdog74 advice and used module re to extract numeric strings: [php]import re data_raw = """[20] [ 35+ ] age = 40 (84) 100kg $245 """ # use regex module re to extract numeric string data_list = re.findall(r"\d+",data_raw) …

Member Avatar for bumsfeld
0
1K
Member Avatar for sneekula

I looked at Ene's wxPython remake of vegaseat's fancy Tkinter GUI "Hello World!" code, and used the Boa Constructor IDE to do this. It took only a few minutes to create this wxPython code, since Boa has a drag/drop frame builder and writes most of the code: [code=python]# fancy "Hello …

Member Avatar for sneekula
0
1K
Member Avatar for wandie

Thanks this info ghostdog! You must be one great regex expert! re.findall(r"(\d+)",data_raw) works great on raw_data, but when I changed 40 to 40.5 it gave me [..., '40', '5', ...] Looks like '\d+ only works on integers. Do you have any suggestions for floats? Maybe I should start new thread? …

Member Avatar for ghostdog74
0
161
Member Avatar for MarkWalker84
Member Avatar for incitatus
Member Avatar for incitatus
0
117
Member Avatar for dams

[QUOTE=woooee;302803]This will print your PYTHONPATH. If the path you want is not listed, and it shouldn't be because your program isn't found, then you have to use sys.path.append to add it.[code] import sys path_list= sys.path for eachPath in path_list : print eachPath[/code][/QUOTE] PYTHONPATH is only used by Python internally to …

Member Avatar for dams
0
127
Member Avatar for Extremist

Not too long ago I wrote Python program to check the onset and degree of color blindness. Actually posted the beginnings of it as snippet here: [url]http://www.daniweb.com/code/snippet457.html[/url] If you are interested in things medical, you can check out BioPython at: [url]http://biopython.org/wiki/Main_Page[/url]

Member Avatar for jrcagle
0
329
Member Avatar for Matt Tacular

Pack it into a function then you can use it again and again: [php]def get_integer(): '''loops until integer value is entered, then returns it''' while True: try: num = int(raw_input("Enter integer number: ")) return num except ValueError: print "Please, enter integer number!" # get integer value from the user val …

Member Avatar for bumsfeld
0
186
Member Avatar for babutche

This puts little more light on it: [code]def fib(n): print "Computing fib:", n if 0 < n < 3: value = 1 print "1Returning value: ", value elif n == 0: value = 0 print "2Returning value: ", value else: value = fib(n-1)+fib(n-2) print "3Returning value: ", value return value …

Member Avatar for babutche
0
129
Member Avatar for seasou

I think wxPython demos were written by my C++ professor or his father. He always uses the C++ trick of putting in obscure header files, to make student's life harder! I have simplified some code that works without those extra imports at: [url]http://www.daniweb.com/code/snippet615.html[/url]

Member Avatar for seasou
0
2K
Member Avatar for mattyd

[QUOTE=sharky_machine;283870]Lists are mutable, Dictionaries are not.[/QUOTE]That is not true! Dictionaries are mutable! However, you cannot use mutable objects like lists and yes dictionaries for the key. Dictionary values can be most anything. Study some more and experiment with this interesting container. If you get stuck, ask more questions!

Member Avatar for jrcagle
0
82
Member Avatar for dunderhead

You might have to destroy the dialog after it has been used: [code] ### 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 selected" dlg.Destroy() ### ###################### [/code]

Member Avatar for vegaseat
0
459
Member Avatar for jrcagle

I think it depends on the version of Windows XP. I can repeat vegaseat's observation on my folks old desktop computer, but import uses the updated pyc file right away on a friend's brandnew laptop with the latest version of Windows XP. Does anyone now how to display the version …

Member Avatar for vegaseat
0
118
Member Avatar for sneekula

Rather than putting your selected line into Label, put it into Entry. Now you can edit it. Bind the Entry to double mouse click to load it back into Listbox at the index sel[0] you have.

Member Avatar for vegaseat
0
2K
Member Avatar for sliver_752

My advice, use the little utility at: [url]http://www.daniweb.com/code/snippet499.html[/url] Since this is GUI program you need to change 'console' to 'window' and give your filename .pyw extension.

Member Avatar for sliver_752
0
106
Member Avatar for sneekula

Accidental endless loops are the once you have to watch out for. The 'while loop' is more prone to this either through faulty escape logic or accidental use of the control variable: [php]# accidental endless loop # this is okay in Python for k in range(10): k = 2 print …

Member Avatar for bumsfeld
0
131
Member Avatar for katharnakh

For German characters I have found it simpler to replace them with acceptable equivalents. Here is an example: [code]# -*- coding: iso-8859-15 -*- str1 = 'Activest-Aktien-Großbritannien' print str1 # test str1 = str1.replace('ß', 'ss') print str1 # test str2 = 'Überländliche Fracht' print str2 str2 = str2.replace('Ü', 'Ue') str2 = …

Member Avatar for bumsfeld
0
154
Member Avatar for sneekula

Here are simple programs. The console version: [code=python]# console sales tax program while True: price = float(raw_input("Enter purchase price: ")) # prevent division by zero error if price != 0: break else: print "price can not be zero!" tax = float(raw_input("Enter sales tax paid: ")) percent = 100 * tax …

Member Avatar for vegaseat
0
435
Member Avatar for Mouche

For your information, a few nice folks are working on a 'Python Tkinter GUI Builder' (ptkgb), that allows you to drag and drop Tkinter widgets on one form similar to the Delphi RAD or MS Visual stuff. Take a look at: [url]http://sourceforge.net/projects/ptkgb/[/url]

Member Avatar for vegaseat
0
10K
Member Avatar for mushroom_jar

The easiest way would be to use: [code]import os os.system("echo $BASH_VERSION") [/code]

Member Avatar for bumsfeld
0
50
Member Avatar for Mouche

Expanding on mawe's formula builder, this is my contribution to the equation solver: [code=python]# evaluate equation like 3x^2+2(3x-2) = 0 import re # look for digit before alpha and '(' pattern = re.compile("(\d)([A-Za-z(])") formula_raw = "3x^2+2(3x-2)" # insert '*' between digit and alpha or '(' formula = re.sub(pattern, r"\1*\2", formula_raw) …

Member Avatar for Mouche
0
212
Member Avatar for MarkWalker84

Is this the same as thread [url]http://www.daniweb.com/techtalkforums/thread60334.html[/url] ???

Member Avatar for bumsfeld
0
118
Member Avatar for The Dude
Member Avatar for Gorilla

MSVCR71.dll is the Microsoft runtime C++ library. I don't think Py2Exe is going to mess with that! You can distribute that file, but you cannot change it or get the wrath of big MS! Jython compiles Python source code down to Java bytecodes which can run directly on a JVM. …

Member Avatar for bumsfeld
0
179
Member Avatar for MarkWalker84

Nice wxPython code! MSVCP71.dll is the Microsoft C++ runtime library used by wxPython. You should install it in C:\WINDOWS\system32\. That should take care of your problems. I noticed you are using Python25, make sure that wxPython and Py2Exe are also for that version of Python.

Member Avatar for bumsfeld
0
119
Member Avatar for jrcagle

Sorry, I don't use Tkinter much, mostly wxPython. It looks to me that in (3) you are overwriting whatever has been in self.level_string with "Level: ".

Member Avatar for bumsfeld
0
94
Member Avatar for JyotiC

Seems that Linux folks use GTK and pygtk for GUI work. It looks like a good GUI, but I use the Windows OS and the whole installation process of GTK/pygtk and all the additional required things is very cumbersome. I personally like wxPython a lot. Why did you choose to …

Member Avatar for JyotiC
0
87
Member Avatar for sneekula

I am studying C++ right now in school (not my choice), and being used to Python the endless type declarations, memory allocations, and pointer this, and pointer that, to achieve very simple stuff, is cumbersome at best. Function arguments are handled with such elegance in Python!

Member Avatar for jrcagle
0
143
Member Avatar for macca1111

Rightclick the IDLE icon and check Properties. You may notice that it still wants to run under Python23. Create a shortcut of Idle.pyw in the Python25/Lib/idellib/ directory and drag it onto your display panel. Use this new icon to run IDLE.

Member Avatar for macca1111
0
83

The End.