4,305 Posted Topics

Member Avatar for reRanger

To further your learning experience take a look at: [url]http://www.daniweb.com/techtalkforums/post257347-78.html[/url] I think this is related to something you are working on.

Member Avatar for vegaseat
0
140
Member Avatar for Gorilla

Here are the basics of commandline arguments ... [code]# commandline arguments import sys print sys.argv[0] # prints the filename of your script print sys.argv[1] # the first parameter print sys.argv[2] # the second parameter #or print sys.argv[1:] # all parameters [/code]sys.arg[1] and higher is only present if you give enough …

Member Avatar for Gorilla
0
132
Member Avatar for rati

Here is a small project, go through all the functions listed at: [url]http://www.phim.unibe.ch/comp_doc/c_manual/C/FUNCTIONS/funcref.htm[/url] and come up with a code sample of a practical application for each function.

Member Avatar for rati
1
116
Member Avatar for reRanger

I am a little confused, hope this will help ... [php]# create a row of colorful buttons and assign some action to each from Tkinter import * def action1(): label1.config(text='You pressed button1') def action2(): label1.config(text='You pressed button2') def rng(): label1.config(text='Now you could be running an RNG!') form1 = Tk() form1.title('Press …

Member Avatar for reRanger
0
181
Member Avatar for Matt Tacular

The Python module glob will get you there ... [code]# get all the file types in a given directory: import os, glob # change to the desired directory os.chdir("C:/Documents and Settings/Matt/Desktop") # get all the files in that directory into a list file_list = glob.glob("*.*") # show the list print …

Member Avatar for Matt Tacular
0
403
Member Avatar for canerkocamaz

Function line.replace(" ","\t") works very well, but it may depend on how many spaces your tab is set at in your editor, as you look at the result. You could use double tabs like line.replace(" ","\t\t"). To add a commandline argument, change this part of the code ... [code]# read …

Member Avatar for vegaseat
0
100
Member Avatar for reRanger

Since you initially allow duplicates and then want to change them you should use a list. A set would automatically eliminate a duplicate element, not what you want. See, if you can use something like this ... [php]# go through each item in a list of strings and make each …

Member Avatar for vegaseat
0
122
Member Avatar for msaenz

To get a hang of the basics of Python, I would recommend the book "Learning Python" by Mark Lutz and David Ascher, published by O'Reilly (no relation to the buffoon on TV!)

Member Avatar for msaenz
0
151
Member Avatar for whisper

Ouch! This is not an easy project for a newbie! I corrected some things in your code to make it work at least ... [code]from Tkinter import * def press_a(event): # you are mixing console and GUI #print 'You Pressed a' # try this ... root.title('You Pressed a') def press_b(event): …

Member Avatar for whisper
0
82
Member Avatar for MIGSoft
Member Avatar for FireSBurnsmuP
0
966
Member Avatar for reRanger

Something like this might work for you ... [php]# load and display several images using Tkinter # Tkinter reads only GIF and PGM/PPM images # (for additional formats use Image, ImageTk from PIL) from Tkinter import * root = Tk() root.title("Click me!") def next_image(event): """toggle between image2 and image3""" global …

Member Avatar for reRanger
0
8K
Member Avatar for Peagles

This is going to be tough, because "print a" gives you a string consisting of two hex values --> '\xc4\x93'. The function ord() seems to only handle single characters. This works ... [code]>>> b = unichr(275) >>> b u'\u0113' >>> ord(b) 275 [/code] Is there a way to decode('utf8')? Sorry, …

Member Avatar for Ene Uran
0
1K
Member Avatar for jrcagle

Removing a directory, all subdirectories and files seems to be a consequential operation, and I would error prove it to the hilt.

Member Avatar for vegaseat
0
122
Member Avatar for Matt Tacular

If with .doc file you mean a MS Word file, no way! Just look at a typical Word .doc file with an editor and you will know why.

Member Avatar for jrcagle
0
145
Member Avatar for dunderhead

You have to reference dalabel via DisFrame --> frame --> Panel1, so it ends up frame.Panel1.dalabel.SetLabel(str(time.time()))

Member Avatar for dunderhead
0
279
Member Avatar for sylvaticus

Excerpt from a heated discussion a while back: [QUOTE]... or Django, or Turbogears, which provide a Ruby-on-Rails like framework to construct your web-app on. Turbogears uses CherryPy, incidentally, but also adds in a templating system (Kid) and a database persistance layer (SQLObject). Django does something similar, and also provides an …

Member Avatar for vegaseat
0
99
Member Avatar for jrcagle

Thanks for sharing this insight! [QUOTE]eval(str) Evaluate a string and return an object[/QUOTE]

Member Avatar for vegaseat
0
291
Member Avatar for jrcagle

Python to the rescue ... [code]def test1(): """In this documentation string the indentation becomes part of the string""" pass print test1.__doc__ print def test2(): """ This is why Python relaxes the indentation rules within a multiline string to allow this kind of documentation string """ pass print test2.__doc__ [/code]

Member Avatar for vegaseat
0
283
Member Avatar for reRanger

Just a few quick questions: What operating system are you running? What version of Python do you have installed? Are you saving your Python files as .py files? Do you use an IDE, which one?

Member Avatar for vegaseat
0
136
Member Avatar for chris99

You are very close, very nice list compare by the way! Avoid anything within the while loop that slows things down, like print statements. You also don't need any list sorting. Here would be my suggestion ... [code]import random def computer_random(): """Let computer create a list of 6 unique random …

Member Avatar for vegaseat
0
131
Member Avatar for jan1024188

Simply add the outer while loop to exit only on option zero: [code]import os selection = 1 while selection != 0: while True: print print "PROGRAM MENU" print "1 - open xmms" print "2 - open emacs" print "3 - open gparted" print "4 - open gedit" print "5 - …

Member Avatar for jan1024188
0
145
Member Avatar for chris99

Nice idea! Do you want to do more? Take a close look at the US flag, it's a bit more complicated. [url]http://www.crwflags.com/fotw/flags/us.html[/url]

Member Avatar for chris99
0
132
Member Avatar for chris99

Looks like you are getting familiar with formatted strings and string input, great! Could be quite funny depending on what you put in!

Member Avatar for chris99
0
164
Member Avatar for GsxRacer

Listen to Dave's advice, he netted them all! Let int main() return something like a zero, rather than an empty plate. Sounds like my kind of menu. What's for DESSERT?

Member Avatar for andor
1
224
Member Avatar for chris99

See my comments in the code ... [code]from Tkinter import * def calculate(): try: metre = float(enter1.get()) result = metre * 100 #label2 = Label(calculate, bg="blue") # error here label2 = Label(root, bg="blue") # black text on blue is hard to see! label2.grid(row=3, column=0) # this was missing label2.config(text=str(metre)+ 'meters …

Member Avatar for chris99
0
143
Member Avatar for katharnakh

Note that transient() is not a built-in method of Python. Which module are you importing?

Member Avatar for vegaseat
0
272
Member Avatar for chris99

IDLE is simply an environment you write your Python programs in. It is basically a text editor you can run your code from. You can do simple graphics with Tkinter that is already part of the Python distribution. For more advanced graphics download PIL. It among other things expands Tkinter's …

Member Avatar for mostafadotnet
0
133
Member Avatar for chris99

Maybe this will help you ... [code]import time print time.ctime() # Sat Sep 02 18:23:53 2006 # get just hr, min, sec of present time tuple hr, min, sec = time.localtime()[3:6] print hr, min, sec # 18 23 53 print sec, type(sec) # 53 <type 'int'> # if you just …

Member Avatar for Ene Uran
0
286
Member Avatar for Dave Sinkula

To get happy it's Southern Comfort straight up! To quench the thirst it's red California table wine like a decent Cabernet Sauvignon with about 1/3 orange juice all ice cold! When gambling I like to keep my wits and drink hot chocolate.

Member Avatar for UrbanKhoja
0
1K
Member Avatar for katharnakh

Smart observation a1eio! Using Python's builtin function names for a variable name seems to trip plenty of new programmers. I got tripped on str when I started writing Python code. Module names can also trip you up! Use the following to check for names you want to avoid ... [code]help("__builtin__") …

Member Avatar for vegaseat
0
2K
Member Avatar for Ene Uran

A closure is a block of code that can be passed as an argument to a function call. In languages like Lisp and Ruby closures are easily implemented. In Python you can do it, but it is a bit more code. Lambda is often used for that. Here would be …

Member Avatar for Ene Uran
0
286
Member Avatar for dannyfang

[QUOTE=Dave Sinkula][FONT=Courier New]itoa[/FONT] is nonstandard; [FONT=Courier New]sprintf[/FONT] is standard. [FONT=Courier New]#include <iostream.h>[/FONT] is nonstandard; [FONT=Courier New]#include <iostream>[/FONT] is standard.[/QUOTE] Dave is correct here, itoa() is not ANSI-C, but supported by most compilers.

Member Avatar for Dave Sinkula
0
333
Member Avatar for Matt Tacular

Matt, as I look at your initial GUI code I can see two problems not related to Tkinter. I marked them with # !!!!!!!!!!!!!!!!, those will be errors! [php]from Tkinter import * def addMen(): addMenC = input("Where do you wish to add men? (country 1,2,3 or 4):") addMenLoop = True …

Member Avatar for vegaseat
0
213
Member Avatar for riddz_22

You can use the command shell: [code]# with windows import os os.system("CLS") [/code] or [code]# with linux import os os.system('clear') [/code] or [code] # if you don't mind that the cursor is at the bottom print '\n' * 25 [/code] Actually, the best way is to design your program so …

Member Avatar for pty
0
180
Member Avatar for lekshmi200
Member Avatar for vegaseat

The code portion of one of my snippets does not always show. [url]http://www.daniweb.com/code/snippet451.html[/url] It's there when I check with edit. I resubmit and it's there for the moment only. Need help!

Member Avatar for iamthwee
0
123
Member Avatar for Ene Uran

On the road again ... Found this example on my notebook computer: [code=python]import wx class MyFrame(wx.Frame): """frame with panel containing two labels and two textcontrols""" def __init__(self): wx.Frame.__init__(self, None, -1, 'wx.FlexGridSizer', size=(350, 100)) panel = wx.Panel(self, -1) basicLabel = wx.StaticText(panel, -1, "Basic wx.TextCtrl:") # size height = -1 implies height …

Member Avatar for Ene Uran
0
816
Member Avatar for zx9
Member Avatar for giles

I recommend Visual C# .Net. You can pick up the whole package for less than $100 (amazon.com). You need Windows on your computer, preferably XP and a good amount of free disk space. It is easy to bring in graphics, color and sound through the various components in the builder. …

Member Avatar for Covinus
0
362
Member Avatar for Jayzilla

Looks like a nice program. On my computer (OS = Windows XP) the last tkMessageBox.showinfo() prevents any focus on entry1, no cursor! Strange indeed!

Member Avatar for bumsfeld
0
129
Member Avatar for bumsfeld

The tuple and the list have a few things in common. They are both indexed containers for objects. The tuple is a very simple container to put some objects together, separated by commas, so you can send them to and from functions or stick them into lists as a group …

Member Avatar for jrcagle
0
175
Member Avatar for MIGSoft
Member Avatar for carolraydon
0
658
Member Avatar for msaenz

How familiar are you with Python? I noticed in your code that the statement after "if key in index:", or the statements in the function "def get_accession_num(fasta_record):" are not properly indented to form a block. Also where does index come from? Can you show us a short sample of your …

Member Avatar for vegaseat
0
131
Member Avatar for girish_sahani
Member Avatar for Ene Uran

The functions are contained in module os. Function os.path.getmtime() gives you the last modified time in seconds since the beginning of 1/1/1970 (epoch). You have to do some formatting with module time functions to make it readable for the ordinary mortal. The size of the file is returned by os.path.getsize() …

Member Avatar for bumsfeld
0
668
Member Avatar for leb

A while back I wrote a little snippet about turtle graphics, just to introduce people to the fact that it exists within Tkinter. It simply draws a bunch of shifted squares that could form some kind of graphical art. Take a look at it and experiment with your own design: …

Member Avatar for Jayzilla
0
108
Member Avatar for vegaseat

In case you are curious, I just posted a new tutorial "Python and Multimedia, Part 1, The amazing Webbrowser Module" on DaniWeb at: [url]http://www.daniweb.com/tutorials/tutorial47392.html[/url] I would love some input from our Linux and Unix friends to see how much cross platform the module is. Post any comments in this thread!

Member Avatar for vegaseat
0
201
Member Avatar for Blujacker

Here is a typical example of a wx.Menu() ... [code=python]# a wxPython Frame with menu, statusbar and about dialog import wx import os # give the ids a unique integer value ID_ABOUT = 101 ID_OPEN = 102 ID_EXIT = 103 class MyFrame(wx.Frame): """frame with menu, statusbar and about dialog, inherits …

Member Avatar for vegaseat
0
147
Member Avatar for vegaseat

The DaniWeb community is pretty worldly, so I though it would be interesting to post the price of beer in your local pub. Be somewhat informative: Here in the state of Nevada I like to go to Barley's Casino and Brewing Company. A pitcher (60 ounces) of Red Rock lager …

Member Avatar for GriffIT34
0
420
Member Avatar for Blujacker

Take a look at the wxButton demo at: [url]http://www.daniweb.com/code/snippet502.html[/url] You might have to modify the events slightly. wx.EVT_BUTTON is basically a single left mouse click. wx.EVT_LEFT_DCLICK is your left double click.

Member Avatar for vegaseat
0
101

The End.