Search Results

Showing results 1 to 40 of 51
Search took 0.01 seconds.
Search: Posts Made By: Ene Uran ; Forum: Python and child forums
Forum: Python 13 Days Ago
Replies: 3
Views: 136
Posted By Ene Uran
There is some important information missing here. What module are you using/importing?

Also I have a dislike for people who post two threads on the same subject. That is very rude. Which one of...
Forum: Python Sep 29th, 2009
Replies: 22
Views: 990
Posted By Ene Uran
This problem has been around for a long time and not just with Python:
# the "Microsoft kludge", quoting a string within a string fixes the
# space-in-folder-name problem, tells the OS to use the...
Forum: Python Sep 27th, 2009
Replies: 20
Solved: Text Files
Views: 596
Posted By Ene Uran
See if something like this will do, but be careful that all the slicing doesn't steal some data:
def extract_number(data_str):
"""
extract the numeric value from a string
(the string...
Forum: Python Sep 26th, 2009
Replies: 80
Views: 17,433
Posted By Ene Uran
There is another Python version called IronPython that uses Python syntax. It runs independent from the normal CPython version and allows access to the large GUI libraries of .NET and Mono. Here is...
Forum: Python Sep 7th, 2009
Replies: 80
Views: 17,433
Posted By Ene Uran
A similar table, this time we use PyQT's QTableView and QAbstractTableModel which allows the items in the table to be sorted by simply clicking on the header titles:
# use PyQT's QTableView and...
Forum: Python Sep 7th, 2009
Replies: 80
Views: 17,433
Posted By Ene Uran
Thanks vegaseat for the newer PyQT style info. Here is a relatively simple way to display tabular data using a function to create an html coded table:
# PyQT's QLabel widget can display html...
Forum: Python Sep 5th, 2009
Replies: 2
Views: 328
Posted By Ene Uran
Look over this code sample, it should be very explanatory:
# role of self in Python classes
# self can be named different, but 'self' is convention

class Snake:
def __init__(self, name):
...
Forum: Python Sep 3rd, 2009
Replies: 2
Views: 247
Posted By Ene Uran
Take a look at:
http://sourceforge.net/projects/pyexcelerator/

Here is example code:
http://sujitpal.blogspot.com/2007/02/python-script-to-convert-csv-files-to.html
Forum: Python Sep 3rd, 2009
Replies: 80
Views: 17,433
Posted By Ene Uran
A quick look at Tkinter's radio and check buttons:
# exploring multiple Tkinter radio buttons
# radio buttons only allow one item to be selected/checked
# ene

try:
# Python2
import...
Forum: Python Aug 27th, 2009
Replies: 80
Views: 17,433
Posted By Ene Uran
An enlightening look at Tkinter's grid layout manager:
# looking at the Tkinter grid() layout manager
#
# The size of a grid cell in a given row or column is
# determined by its largest widget....
Forum: Python Jul 8th, 2009
Replies: 4
Views: 295
Posted By Ene Uran
Simply use list():
list1 = ['a', 'b', 'c', 'd']
# this will create a new list with a different mem ref
temp_list1 = list(list1)
for i in range(len(list1)):
temp_list1[i] = "1"
print list1; ...
Forum: Python Jul 7th, 2009
Replies: 6
Views: 382
Posted By Ene Uran
You mean something like this:
# data string read from a file
data = """\
gnl|dbSNP|rs13484118 gi|62750812|ref|NC_005111.2|NC_005111 95 20 1 0 68 87 31017559 31017578 4.4 32.3
gnl|dbSNP|rs13484118...
Forum: Python Jul 6th, 2009
Replies: 1
Views: 774
Posted By Ene Uran
In Python it would look like:
fout = open("test1.txt", "w")
fout.write("save something ...\n")
fout.write("save something more ...\n")
fout.close()

# or C++ style (allowed in Python2)
fout =...
Forum: Python Jul 5th, 2009
Replies: 80
Views: 17,433
Posted By Ene Uran
Here is a general notebook widget class for Tkinter:
# testing a notebook widget class for Tkinter (modified)
# Python 2.5.4 ene

import Tkinter as tk

class Notebook(object):
"""
a...
Forum: Python Jun 17th, 2009
Replies: 80
Views: 17,433
Posted By Ene Uran
PyQT has an interesting widget called a dial (circular slider). Here is a simple applcation:
# use a PyQT QDial knob to select a temperature
# show Celsius and corresponding Fahrenheit values
#...
Forum: Python Jun 13th, 2009
Replies: 80
Views: 17,433
Posted By Ene Uran
Draw a simple bar chart with PyQT:
# use PyQT to draw a simple vertical bar chart
# tested with PyQT4.5 and Python3.0
# ene

import sys
# simplified import, hopefully no namespace conflicts...
Forum: Python Jun 13th, 2009
Replies: 130
Views: 49,710
Posted By Ene Uran
I think we may have talked about this before, but I can't find it. Here is a way to use a sound file inside the Python code and play it. First create a base64 encoded string of the binary sound...
Forum: Python May 24th, 2009
Replies: 80
Views: 17,433
Posted By Ene Uran
Tkinter has some nice pop-up dialogs that can also be used for regular console programs. Here is an example to use if you want to get a filename from a pop-up window. It works with Python2x or...
Forum: Python May 19th, 2009
Replies: 9
Views: 555
Posted By Ene Uran
Here is an example without a titlebar and showing fullscreen:
# wx.Frame with no title bar and showing fullscreen
# modified from vegaseat's example

import wx

def exit(event):
...
Forum: Python May 13th, 2009
Replies: 80
Views: 17,433
Posted By Ene Uran
A small Python/PyQT4 utility program to find out what kind of fonts your computer has:
# bring up a font dialog with PyQT4
# show the selected font using a sample text

import sys
# hopefully no...
Forum: Python May 12th, 2009
Replies: 80
Views: 17,433
Posted By Ene Uran
An example how to use the QPainter to create a wallpaper background:
# a simple window using PyQT
# using a canvas with a texture/wallpaper background

import sys
# pray for minimal namespace...
Forum: Python May 12th, 2009
Replies: 80
Views: 17,433
Posted By Ene Uran
I got PyQT4 istalled and working on my Vista computer. Here is an example of my first program:
# display a bunch of random circles using PyQT4

import random
import sys
# pray for minimal...
Forum: Python Feb 16th, 2009
Replies: 2
Views: 1,002
Posted By Ene Uran
Expanding on jrcagle post:
import shutil

source_file = r"C:\Python25\Atest\Bull\shutil_test.txt"
destination = r"C:\Python25\Atest\Bull\Test"

# this copies the source file to the destination...
Forum: Python Feb 13th, 2009
Replies: 5
Views: 635
Posted By Ene Uran
Oh yes, Python has an array type, but you must import module array:
# module array has Python's array type

import array

# Python25 use 'c' as the character typecode
# Python30 uses unicode...
Forum: Python Feb 5th, 2009
Replies: 2
Views: 267
Posted By Ene Uran
Two loops will do, or you can use a list comprehension:
rank = ("A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K")
suit = ("c", "h", "s", "d")

card = []
for r in rank:
for s...
Forum: Python Jan 26th, 2009
Replies: 8
Views: 3,146
Posted By Ene Uran
For the time being you will have to use good old Tkinter that ships with Python3.0.
Forum: Python Jan 24th, 2009
Replies: 2
Views: 751
Posted By Ene Uran
You simply append the directory to PYTHONPATH before you import your custom module:
import sys
# appends to PYTHONPATH the location of the example codes
sys.path.append(r'C:\Python25\Examples')
Forum: Python Oct 21st, 2008
Replies: 8
Views: 769
Posted By Ene Uran
Here is a general example you can adopt, let us know if it works for your case:
# using module subprocess to pass arguments to and from an
# external program

import subprocess

# put in the...
Forum: Python Sep 26th, 2008
Replies: 10
Views: 1,617
Posted By Ene Uran
Why do all the extra work, if Python can do it for you?
result3=[
83,97,109,117,101,108,32,83,109,105,116,104,13,10,13,10,84,
104,97,110,107,32,121,111,117,32,102,111,114,32,108,111,111,...
Forum: Python Aug 24th, 2008
Replies: 130
Views: 49,710
Posted By Ene Uran
To create a window or frame with wxPython you use wx.Frame. There are some basic things you can do with a frame and I tried to put them in one spot:
# a few things you can do with wxPython's...
Forum: Python Jul 29th, 2008
Replies: 130
Views: 49,710
Posted By Ene Uran
The information a statusbar can display can come handy:
# set up a customized statusbar with three display fields
# a statusbar is typically an information line at the bottom of a window

import...
Forum: Python Jun 30th, 2008
Replies: 130
Views: 49,710
Posted By Ene Uran
Trapping a key event:
# bind keyevent to key down and display the key value

import wx

class KeyEvent(wx.Frame):
def __init__(self, parent, id, title):
wx.Frame.__init__(self,...
Forum: Python Jun 30th, 2008
Replies: 130
Views: 49,710
Posted By Ene Uran
The wxPython GUI toolkit has a number of ways to specify colors, or should I say colours. Here is a simple example:
# show different ways to specify colours with wxPython

import wx

class...
Forum: Python Jun 9th, 2008
Replies: 130
Views: 49,710
Posted By Ene Uran
To draw simple shapes like lines, circles, rectangles you have to use the wx.PaintDC surface as the canvas. Here are some basic examples:
# the wx.PaintDC surface is wxPython's canvas
# draw a...
Forum: Python Jun 9th, 2008
Replies: 130
Views: 49,710
Posted By Ene Uran
Here is a templet file that allows you to package your wxPython program to an executable file with the py2exe module. It contains an XML manifest that gives the wxPython widgets a Windows XP...
Forum: Python Mar 24th, 2008
Replies: 3
Views: 848
Posted By Ene Uran
I think Tkinter is written in TCL language with a Python wrapper hanging over it. If you want to write a new widget you better learn TCL.

I fooled around a little with the scale widget itself and...
Forum: Python Jan 19th, 2008
Replies: 4
Views: 1,604
Posted By Ene Uran
There is no simple dictionary function build in, since values may not be unique, but you can use this:
# search a dictionary for key or value

def find_key(dic, val):
"""return the key of...
Forum: Python Dec 22nd, 2007
Replies: 2
Views: 966
Posted By Ene Uran
Great, let us know what you like. I still use DrPython for most of my Python programming, but also like PyScripter (gets better all the time, they are still updating).
Forum: Python Apr 21st, 2007
Replies: 8
Code Snippet: Plotting with Pylab
Views: 39,140
Posted By Ene Uran
You can download the matplotlib free from: http://matplotlib.sourceforge.net/
It has, amongst many other things, the module pylab that allows for high quality plotting of data. All you have to do...
Forum: Python Feb 8th, 2007
Replies: 12
Views: 4,857
Posted By Ene Uran
A couple of things wrong with your countdown timer.
1 - don't limit the size of your root window, widgets won't fit
2 - labels take strings
3 - root.update() is needed
Look this over:
#Gamal...
Showing results 1 to 40 of 51

 


About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC