4,305 Posted Topics
Re: 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 … | |
Re: 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 … | |
Re: Actually [B][ma2, ma3, ma4][/B] would imply a list of variable names. You have to let Python know what those variable names represent. | |
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 … | |
Re: 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 | |
Re: 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) … | |
Re: 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): … | |
Re: 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 … | |
Re: This example might give you a hint: [url]http://www.daniweb.com/software-development/python/threads/128350/1560029#post1560029[/url] | |
Re: 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] | |
Re: The way you do it, soiling the internet with spam. | |
| |
Re: Take a look at: [url]http://www.daniweb.com/software-development/python/code/254039[/url] | |
Re: 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!) … | |
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 … | |
Re: Take a quick look at: [url]http://rpy.sourceforge.net/rpy_demo.html[/url] | |
Re: 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. | |
Re: William "Refrigerator" Perry from the Chicago Bears. He would carry the ball along with five opposing players into the end zone. | |
Re: 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 … | |
Re: 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. :) | |
| |
Re: Python module calendar might just be simpler. See: [url]http://www.daniweb.com/software-development/legacy-and-other-languages/threads/362098/1554079#post1554079[/url] | |
Re: 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 … | |
Re: 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 # … | |
Re: 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 … | |
Re: 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 ] # … | |
Re: This code is using the Zelle graphics module (derived from Tkinter) free from: [url]http://mcsp.wartburg.edu/zelle/python/graphics.py[/url] | |
Re: 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, … | |
Re: 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 … | |
Re: "Deep Impact" with Elijah Wood, Maximillian Schell and Tea Leoni. A great Science Fiction movie with top stars and effects. | |
Re: This could be helpful: [url]http://users.rcn.com/python/download/Descriptor.htm[/url] | |
Re: 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 … | |
Re: 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" … | |
Re: 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 … | |
Re: 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] | |
| |
Re: 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] | |
Re: 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) # … | |
Re: I drink coffee when I get tired of tea | |
Re: Binary search also needs a sorted list. | |
Re: 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 … | |
Re: 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. | |
Re: 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. | |
Re: 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. | |
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 … | |
Re: For proper pygame code see: [url]http://www.daniweb.com/software-development/python/threads/191210/1542986#post1542986[/url] | |
Re: I am addicted to pursuit of happiness. Sometimes my own, sometimes other folks. | |
Re: 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 … | |
Re: 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 | |
Re: 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 … |
The End.