4,305 Posted Topics

Member Avatar for imperialguy

The only wxPython widget that has a build-in timeout is wx.SplashScreen(). Your message however has be inside an image file. This can easily be done with a small wxPython program or any of the many image editors. Take a look at: [url]http://www.daniweb.com/software-development/python/threads/128350/1560030#post1560030[/url] Any of the dialog boxes rely on a …

Member Avatar for vegaseat
0
1K
Member Avatar for Ephexeve

Here is an example ... [code]# exploring Python2 callable(object) # in Python3 this changes to (need to import collections) ... # isinstance(object, collections.Callable), class C: pass def funk(): return 1234 # notice the () used to call a class or function instance_c = C() numbers = funk() print(callable(C)) # True …

Member Avatar for TrustyTony
0
277
Member Avatar for rssk

Actually [B][ma2, ma3, ma4][/B] would imply a list of variable names. You have to let Python know what those variable names represent.

Member Avatar for TrustyTony
0
222
Member Avatar for vegaseat

Continued fraction expansion is a simple way to approximate common trigonometry functions to a relatively high precision. In this example we only look at sin and cosine. The results compare well with the results of high precision packages like SymPy. The Python module decimal is used to achieve the high …

Member Avatar for TrustyTony
3
566
Member Avatar for novice20

In my clutter of old USB flash cards I found a copy of Movable Python24, it does not give any problem with the original code

Member Avatar for novice20
0
232
Member Avatar for WolfShield

Why don't you use the Entry widget from tkinter? Module ttk uses Style(), more powerful, but much more complex. [code]from tkinter import * from tkinter import ttk #from BK_functions import * # Create Window root = Tk() root.title("Calculator") root.resizable(False, False) # Calculator TextField dfSV = StringVar() dsplyF = Entry(root, textvariable=dfSV) …

Member Avatar for WolfShield
0
395
Member Avatar for HiHe

Congratulation, you discovered an idiosyncrasy of wx.Frame with just a single widget on it. My advice, use a panel to give the correct layout ... [code]# a simple wxPython GUI program # showing a label with color text # use a panel to give correct layout import wx class MyFrame(wx.Frame): …

Member Avatar for vegaseat
0
311
Member Avatar for jum2011

You need to start out with a GUI toolkit like Tkinter that comes with Python. That will do the actual drawing. The turtle will point in a certain direction and you have to use trigonometry to calculate the length of the line and its end point (x, y) from the …

Member Avatar for vegaseat
0
266
Member Avatar for chrisvj11

This example might give you a hint: [url]http://www.daniweb.com/software-development/python/threads/128350/1560029#post1560029[/url]

Member Avatar for chrisvj11
0
782
Member Avatar for WolfShield

Too much junk in the code, try it this way ... [code]from tkinter import * from tkinter import ttk root = Tk() root.option_add('*tearOff', FALSE) menubar = Menu(root) root.config(menu=menubar) menu_file = Menu(menubar) menu_edit = Menu(menubar) menubar.add_cascade(menu=menu_file, label='File') menubar.add_cascade(menu=menu_edit, label='Edit') menu_file.add_command(label='New', command=None) menu_file.add_command(label='Open...', command=None) menu_file.add_command(label='Close', command=None) root.mainloop() [/code]

Member Avatar for HiHe
0
182
Member Avatar for JhonMoney
Member Avatar for jingda
Member Avatar for sergent
0
149
Member Avatar for izthrower

Take a look at: [url]http://www.daniweb.com/software-development/python/code/254039[/url]

Member Avatar for vegaseat
0
197
Member Avatar for vr3690

Spaces in folder and file names create problems with Windows ... [code]# the Microsoft kludge, quoting a string within a string fixes the # space-in-folder-name problem, tells the OS to use the whole string # including spaces as a single command # (make sure filename does not contain any spaces!) …

Member Avatar for vegaseat
0
230
Member Avatar for vegaseat

You need the Python tkSnack module to play notes of a given frequency and duration on your external sound system (attached to the PC's sound card). The code snippet gives just a tiny hint about the capabilities of tkSnack. It works with Tkinter, normally part of the Python installation. The …

Member Avatar for Layra
3
5K
Member Avatar for nighthawk10
Member Avatar for vegaseat
0
296
Member Avatar for Lardmeister

Well, you are on to something, the tuple has changed. However, the id() of the whole tuple is still the same after the change. My advice, don't rely blindly on tuples not changing as advertised.

Member Avatar for vegaseat
0
187
Member Avatar for Pendukeni

William "Refrigerator" Perry from the Chicago Bears. He would carry the ball along with five opposing players into the end zone.

Member Avatar for jingda
0
163
Member Avatar for maddenfong

cxFreeze is not an executable, but a package called cx_Freeze you need to import to your setup code ... [code]""" con_setup2.exe Using cx_freeze with Python32 to package a console program to an executable file (.exe in Windows OS). Might want to put a console-wait-line in at the end of your …

Member Avatar for vegaseat
0
158
Member Avatar for jingda
Re: UFO?

Not sure why UFOs have to show lights. If it is from outer space, it would have been "on the road" for at least a million years and the lights would have long burned out. :)

Member Avatar for Lardmeister
0
409
Member Avatar for jingda
Member Avatar for TrustyTony

Python module calendar might just be simpler. See: [url]http://www.daniweb.com/software-development/legacy-and-other-languages/threads/362098/1554079#post1554079[/url]

Member Avatar for TrustyTony
1
4K
Member Avatar for gangemia

Since we are talking Python, you can also use Python module calendar ... [code]# print the first workday (Mon - Fri) of each month in a given year # Monday is first day of week by default # tested with Python27 and Python32 by vegaseat import calendar # change these …

Member Avatar for TrustyTony
0
4K
Member Avatar for HiHe

Another way is to run Tkinter and PIL simultaneously. You can save the in memory PIL image in many file formats ... [code]# random circles in Tkinter # a left mouse double click will idle action for 5 seconds and # save the canvas drawing to an image file # …

Member Avatar for HiHe
0
18K
Member Avatar for stan_l

Works fine for me ... [code]Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> >>> import sys, os, wx >>> help("modules") Please wait a moment while I gather a list of all available modules... ArgImagePlugin …

Member Avatar for snippsat
0
487
Member Avatar for RewindPlay

Generally, it pays (no pun intended) to keep your pay list object intact. Save and load it with module pickle. A purely numeric list like that makes the rest of the calculations easy ... [code]# sample list of annual salaries pay_list = [ 35500, 49600, 28450, 75234, 51230 ] # …

Member Avatar for vegaseat
-1
128
Member Avatar for Fo.katia

This code is using the Zelle graphics module (derived from Tkinter) free from: [url]http://mcsp.wartburg.edu/zelle/python/graphics.py[/url]

Member Avatar for vegaseat
0
409
Member Avatar for Niner710

How did you get such a srtange looking numpy array? How will Python know that this is supposed to be a numpy array type? Generally ... [code]# Python list to numpy array and then text string import numpy as np mylist = [ [1000, 2, 3], [4, 5000, 6], [7, …

Member Avatar for vegaseat
0
555
Member Avatar for RewindPlay

You can append your data to a list (or a dictionary of name:data_list pairs) and save it as a list or dictionary object with module pickle. Here is a typical example of pickle ... [code]# use module pickle to save/dump and load a dictionary object # or just about any …

Member Avatar for woooee
0
136
Member Avatar for Arbus

"Deep Impact" with Elijah Wood, Maximillian Schell and Tea Leoni. A great Science Fiction movie with top stars and effects.

Member Avatar for predator78
0
206
Member Avatar for ihatehippies

This could be helpful: [url]http://users.rcn.com/python/download/Descriptor.htm[/url]

Member Avatar for ihatehippies
0
229
Member Avatar for Archenemie

The deque rotate function might be something to consider ... [code]# Caesar Cipher encryption/decryption # using Python's double-ended queue from collections import deque def doCaesarCipher(text, shift): alpha = 'abcdefghijklmnopqrstuvwxyz' dq = deque(alpha) # shift/rotate the alphabet (dq in place) dq.rotate(shift) encrypted = "" for c in text.lower(): if c in …

Member Avatar for Archenemie
0
228
Member Avatar for Venku Tur'Mukan

Here is a practical example ... [code]def get_int(): """this function will loop until an integer is entered""" while True: try: # return breaks out of the endless while loop return int(raw_input("Enter an integer: ")) except ValueError: print("Try again, value entered was not an integer.") myinteger = get_int() print("You entered %d" …

Member Avatar for vegaseat
0
44K
Member Avatar for UnitedForLife

Some practical considerations ... [code]# import all functions in module import module1 # call function func1() module1.func1() # import all functions in module, but use a substitute name import module1 as md md.func1() # import specified function in module from module1 import func1 # call func1 func1() # import specified …

Member Avatar for vegaseat
0
104
Member Avatar for novice20

In Python integers have a size only limited by your computer's memory. If you want to force compatibility with C you can use Python module [B]struct[/B]

Member Avatar for vegaseat
0
9K
Member Avatar for Ancient Dragon
Member Avatar for e-papa
1
331
Member Avatar for pjconrad

You might have an empty list, no data elements in it ... [code]mylist = [] print(mylist) # [] print(len(mylist)) # 0 # empty list will give IndexError: list index out of range print(mylist[0]) [/code]

Member Avatar for TrustyTony
0
1K
Member Avatar for Venku Tur'Mukan

You use 'is' to check the identity of objects ... [code]# 'is' checks object identities # the id is a memory location # in this case Python stores the 7 in the same location a = 7 b = 7 print(id(a)) # 30626568 print(id(b)) # 30626568 print(a is b) # …

Member Avatar for Venku Tur'Mukan
0
805
Member Avatar for skald89
Member Avatar for group256
Member Avatar for Dan08

For a look at pygame sprites see: [url]http://www.cs.iupui.edu/~aharris/pygame/ch06/basicSprite.py[/url] Here is an example for finding the mouse position ... [code]import pygame as pg # pygame uses (r, g, b) tuples for color red = (255, 0, 0) white = (255, 255, 255) screen = pg.display.set_mode((500, 500)) pg.display.set_caption("click the mouse on the …

Member Avatar for TrustyTony
0
3K
Member Avatar for AutoPython

In general, one ought to avoid platform specific code with a cross platform language like Python. This code works only on Windows, the Tkinter approach may look mildly more complex, but it is cross platform.

Member Avatar for TrustyTony
0
7K
Member Avatar for royng

About 70% of Americans who go to college do it just to make more money. The rest of them are avoiding reality for about four more years.

Member Avatar for HiHe
0
565
Member Avatar for HiHe

Those multiple underscores are somewhat of a devil! :) As experts tonyjv and Griboullis pointed out, using [COLOR="Green"]Circle.__init__(self, r)[/COLOR] is much clearer than using super(). The only advantage of super() is with Python3, where you can use it without hard-coding the class name.

Member Avatar for HiHe
0
281
Member Avatar for vegaseat

Probably the simplest way to get into multimedia with Python is the webbrowser module. This works with both Windows and Unix systems, and selects the default browser you have installed. But that is not all: if you give it the name of a multimedia file it will select the default …

Member Avatar for e-papa
4
1K
Member Avatar for Thropian

For proper pygame code see: [url]http://www.daniweb.com/software-development/python/threads/191210/1542986#post1542986[/url]

Member Avatar for vegaseat
0
242
Member Avatar for jingda

I am addicted to pursuit of happiness. Sometimes my own, sometimes other folks.

Member Avatar for ChengYi
0
138
Member Avatar for novice20

To avoid problems define all your functions in the beginning of a program (more readable anyway!) ... [code]def f1(): print('f1') # call function f2 f2() def f2(): print('f2') f3() def f3(): print('f3') # all function have been defined # now this will work f1() [/code]This will give problems ... [code]def …

Member Avatar for novice20
0
4K
Member Avatar for kiranbkrishna

Just a few quick observations: background is the same as bg img might best be self.img how to you go from the button to widget give us the full class so we can help Using i and I as variable names spell trouble in any code

Member Avatar for TrustyTony
0
370
Member Avatar for jarograv

If you can tolerate to use for instance rp[(7, 3)] instead of r7p3, then a dictionary can well represent the 2d array you are talking about. [code]# create a dictionary with (r, p) key tuples # where r is the number after r and p is the number after p …

Member Avatar for woooee
0
205

The End.