Forum: Python 15 Days Ago |
| Replies: 2 Views: 188 Try self.SetSizerAndFit(sizer) |
Forum: Python Oct 19th, 2009 |
| Replies: 6 Views: 296 # staticmethod() and classmethod()
# make it easier to call one class method
class ClassA(object):
def test(this):
print this
test = staticmethod(test)
ClassA.test(4) # 4 |
Forum: Python Aug 25th, 2009 |
| Replies: 78 Views: 14,669 It's like putting single image on PyGame "liquid canvas" giving an eerie visual effect. Here is short code:
# PyGame liquid effect on single image
# just old PyGame example modified
# module... |
Forum: Python Aug 24th, 2009 |
| Replies: 3 Views: 377 niek_e is correct, successful compression depends on the source and the compression algorithm. Here is one example of large repeating text that the zip algorithm fails with, but bz2 compression... |
Forum: Python Aug 22nd, 2009 |
| Replies: 12 Views: 1,209 One rude awakening with Python3 will be the frequent use of bytearrays instead of strings. It does this to handle international unicode better.
Here is how you deal with this:
# get code of... |
Forum: Python Aug 13th, 2009 |
| Replies: 78 Views: 14,669 Retrieve the text from Tkinter Text widget line by line:
# explore the Tkinter Text() widget
# getting text 'line by line' from the widget
# use ctrl+c to copy, ctrl+x to cut selected text,
#... |
Forum: Python Aug 13th, 2009 |
| Replies: 78 Views: 14,669 In the previous example I meant 'Tkinter' rather than 'Tinter'. This however is PyQT example looking at the tooltip widget and some colored text:
# pqt_tooltip1.py
# exploring PyQT's tooltip and... |
Forum: Python Aug 6th, 2009 |
| Replies: 78 Views: 14,669 PyGame isn't the only toolkit you can use for animation. If you use Python 3.1 and still wait for PyGame to be available, you can use Tinter for some simple animations:
# Tk_CanvasMove1.py
#... |
Forum: Python Aug 5th, 2009 |
| Replies: 78 Views: 14,669 Put PyQT widgets on a color background using canvas:
# pqt_CanvasBackGround1.py
# use PyQT's paintEvent to create full frame canvas
# widgets will use the canvas as background
# Henri
import... |
Forum: Python Aug 5th, 2009 |
| Replies: 78 Views: 14,669 Look at PyQT's progress bar widget and simple timer to drive it:
# pqt_progressbar1.py
# explore PyQT's progress bar and simple timer widgets
# Henri
import sys
from PyQt4.QtCore import *... |
Forum: Python Aug 5th, 2009 |
| Replies: 78 Views: 14,669 Exampled code for PyQT's multiline text entry widget:
# pqt_TextEdit1.py
# explore PyQT's QTextEdit multiline text entry box
# click right mouse button in edit area for popup menu
# Henri
... |
Forum: Python Aug 5th, 2009 |
| Replies: 78 Views: 14,669 Sometimes it's nice to attach label to entry widget. One way to do this is with class object:
# pqt_EntryLab1.py
# create labeled data entry areas
# tested with Python 3.1 and PyQT 4.5
# Henri
... |
Forum: Python Aug 4th, 2009 |
| Replies: 78 Views: 14,669 Quick look at PyQT's QListWidget, commonly called 'list box'. Also shows how to create multiple buttons with the for loop. Here is short example:
# pqt_listbox2.py
# explore PyQT's QListWidget... |
Forum: Python Aug 3rd, 2009 |
| Replies: 78 Views: 14,669 One nice graphical way to select calendar date is with the calendar widget. Here is the PyQT example:
# explore the PyQT QCalendarWidget widget
# tested with Python 3.1 and PyQT 4.5
# Henri
... |
Forum: Python Jul 29th, 2009 |
| Replies: 78 Views: 14,669 One more simple way to present data in table form:
# use PyQT's QTableWidget, QTableWidgetItem and setItem
# to show data in simple table format
# tested with Python 3.1 and PyQT 4.5
# Henri
... |
Forum: Python Jul 28th, 2009 |
| Replies: 78 Views: 14,669 Exploring PyQT's QListView and QAbstractListModel. This little code pops up posssible words from word list as you type:
# using PyQT's QListView and QAbstractListModel
# to match partially typed... |
Forum: Python Jul 27th, 2009 |
| Replies: 78 Views: 14,669 Presenting data in the form of a table that can be sorted by column is slick, and relatively easy to do with PyQT's QTableView widget:
# use PyQT's QTableView and QAbstractTableModel
# to present... |
Forum: Python Jul 25th, 2009 |
| Replies: 78 Views: 14,669 Another look at PyQT's canvas:
# pqt_drawtext2.py
# playing with PyQT's QPainter
# setPen, setBrush, setFont, drawRect and drawText
import sys
# simpler import
from PyQt4.QtCore import *... |
Forum: Python Jul 25th, 2009 |
| Replies: 78 Views: 14,669 Looking at PyQT's grid layout manager:
# pqt_gridlayout1.py
# start of small calculator
import sys
# simple general import
from PyQt4.QtCore import *
from PyQt4.QtGui import *
class... |
Forum: Python Jul 20th, 2009 |
| Replies: 78 Views: 14,669 The PyQT GUI toolkit's QLabel widget can actually display HTML formatted text directly. This allows for relatively easy formatting of text:
# PyQT's QLabel widget can display html formatted text
... |
Forum: Python Jul 19th, 2009 |
| Replies: 78 Views: 14,669 Similar to the PyQT GUI example above, the Thinter GUI toolkit also has input dialogs that validate the input:
# Python GUI toolkit Tkinter has 3 different data input dialogs:
#... |
Forum: Python Jul 19th, 2009 |
| Replies: 78 Views: 14,669 Just bought used Dell XP notebook for class work and installed Python 3.1 and then PyQT4 form:
http://www.riverbankcomputing.co.uk/software/pyqt/download
Windows installer (14JUL2009):... |
Forum: Python Jul 27th, 2008 |
| Replies: 127 Views: 46,810 Shows you how to drag one of wxPython's widgets with the mouse pointer:
# use mouse to drag the wx.Panel() widget
# wx.Panel(parent, id, pos, size, style)
import wx
class MyFrame(wx.Frame):
... |
Forum: Python Jul 3rd, 2008 |
| Replies: 127 Views: 46,810 Sneekula left one small starter editor somewhere around DaniWeb. So I took it and modified it to use the wxPython toolbar with icon images rather than Snee's menu bar. The images come from... |
Forum: Python Jun 10th, 2008 |
| Replies: 127 Views: 46,810 Well, if you do web-page designing, you will be familiar with the repeating image tile wallpaper. You can do something similar to give your wxPython frame or panel very sexy backgrounds. I leaned... |
Forum: Python Jun 10th, 2008 |
| Replies: 127 Views: 46,810 Nice stuff there Fuse and Ene!
Here is my contribution, showing you how easy it is to have wxPython display an image from image file:
# show .jpg .png .bmp or .gif image on wx.Panel
import wx
... |
Forum: Python Mar 3rd, 2008 |
| Replies: 3 Views: 2,569 You can do it with label and use spaces of the desired background colour. Here is example:
# Tkinter progress bar experiment
# using label and string of spaces
import Tkinter as tk
root =... |
Forum: Python Jul 4th, 2007 |
| Replies: 3 Views: 1,272 The problem with time.sleep(sec) is that your whole program sleeps unless you thread the background action. So BearofNH's use of time.time() is more appropriate. |
Forum: Python Feb 19th, 2007 |
| Replies: 4 Views: 28,547 Sure Python has multidimensional arrays, they are called lists of lists or tuples of tuples etc.
mlist1 = [
[7, 12, 23],
[22, 31, 9],
[4, 17, 31]]
print mlist1 # [[7, 12, 23], [22, 31, 9],... |
Forum: Python Nov 7th, 2006 |
| Replies: 9 Views: 4,588 Expanding on mawe's formula builder, this is my contribution to the equation solver:
# evaluate equation like 3x^2+2(3x-2) = 0
import re
# look for digit before alpha and '('
pattern =... |
Forum: Python Oct 22nd, 2006 |
| Replies: 1 Views: 1,240 The two functions
num = input("Enter a number: ")
and
name = raw_input("Enter a name: ")
are for the user to enter number or name from the console.
Please use code tags. At end of your code... |
Forum: Python Oct 5th, 2006 |
| Replies: 195 Views: 86,223 You have two similar lists and want to see what items are in list1 that are not in list2 and vice versa. The trick is to convert them into sets and take the difference:
color_list1 =... |
Forum: Python Jul 4th, 2006 |
| Replies: 5 Views: 6,895 This program uses Python module re for splitting a text file into words and removing some common punctuation marks. The word:frequency dictionary is then formed using try/except. In honor of 4th of... |
Forum: Python May 18th, 2006 |
| Replies: 209 Views: 96,957 Write a hex-dump program, where you read a file byte by byte and display the value as a hexadecimal number (base 16). Display about 16 bytes on each row and in a second column next to it show any... |
Forum: Python Feb 11th, 2006 |
| Replies: 209 Views: 96,957 Design a text driven adventure game. Draw a map with features like meadows, woods, mountains, rivers, lakes, caves, cottages and such. You know the map, the player does not! Start in the center... |
Forum: Python Nov 23rd, 2005 |
| Replies: 209 Views: 96,957 If you have five dice, how often do you have to throw (average) the dice to get a hand of four sixes? Try with other poker hands too. |
Forum: Python Oct 16th, 2005 |
| Replies: 209 Views: 96,957 Similar to the color project but with frequency of a tone. The computer plays a tone with random audible frequency. The user tries to match this frequency. In a GUI project can use a slider. ... |
Forum: Python Oct 16th, 2005 |
| Replies: 209 Views: 96,957 This project takes wxPython or maybe Tkinter for GUI. Let the computer pick random color selecting random RGB value. The user has to match the color picking RGB (red, green, blue) values that... |
Forum: Python Sep 17th, 2005 |
| Replies: 209 Views: 96,957 Build a Memory Game. You shortly flash up a number of random words. Lets say three or five, and then ask the player to recall the words from a mutli choice answer. Do that a ten or twenty times... |