324 Posted Topics
I was exploring random art and modified this nice example from vegaseat: [code]# random circles in Tkinter # a left mouse double click will idle action for 5 seconds # modified vegaseat's code from: # http://www.daniweb.com/software-development/python/code/216626 import random as rn import time try: # Python2 import Tkinter as tk except … | |
Re: [B]Basic Instinct[/B] with Michael Douglas and Sharon Stone. Now that's a thriller! | |
![]() | Re: Not all scientists are mad. The problem is that the general public is simply not interested in science. |
Re: I drink coffee to keep from falling asleep. Not sure what does it, probably the awful taste! | |
Re: Compared to a soldier's life, a students life is like going to Sunday School. | |
This works with Python 2.7 [code]class B: def __init__(self, arg): print(arg) class C(B): def __init___(self, arg): super(C, self).__init__(arg) c = C('abc') # abc [/code]Here super() gives a TypeError: must be type, not classobj [code]from math import pi class Circle: """with Python3 object is inherited automagically""" def __init__(self, r): self.r = … | |
Re: A massive galactic gamma ray burst would destroy all living organisms. Except for maybe some gold miners way down underground in South Africa. | |
Re: Two ducks go on their honeymoon and stay in a hotel. As they are about to make love, the duckman says, ''Oh, we haven't got any condoms. I'll ring down to room service.'' So the duckman calls and asks for some condoms. The room service woman says, ''OK sir, would … | |
Re: To go one step further, the working folder is the folder/directory your working file (present program) is in. Run this little program: [code]# save this program as working.py import os # this will show the folder you saved working.py in print( os.getcwd() ) [/code] | |
Re: [QUOTE=dvdreplication;1218852]Its not looks like a forum though but i am feeling comfortable with it, its working well. :)[/QUOTE]Isn't signature spamming fun? What kind of sticks and poor quality DVDs are you unloading on the naive public? Too bad the new design doesn't prevent that. | |
Re: In your case page is a string. To make it a list of lines modify your code this way: [code] document = urllib2.urlopen(url,'r') page_lines = document.readlines() for index, line in enumerate(page_lines): print index [/code] | |
Re: I envy those people to whom "Ignorance is bliss" has a real meaning! | |
Re: However, this will work: self.list_box_1.SetForegroundColour("red") | |
Re: If you are not too good at Python, give Ruby a try! | |
Re: [QUOTE=vandalised;1219445]On that note i'm going to bed, that is really a slap hand on forehead moment (DOH). Its what you get for trying to learn programming at 3am eh? Cheers btw vegaseat[/QUOTE]Happens to the best of us! | |
Re: [QUOTE=ultimatebuster;1214796]Is this needed? [CODE] class Test: def __init__(self, f): self.f = open(f) def __del__(self): try: self.f.close() except: pass [/CODE] Also, how can i open a file, and have it in append mode. However, if the file doesn't exist, python creates it?[/QUOTE] Tha class approach is somewhat awkward, but you could … | |
Yes, you can merge two class instances in this simple manner. | |
The small code shown below works fine with Python26, however Python31 gives an error: fout.write('.snd' + pack('>5L', 24, 8*dur, 2, 8000, 1)) TypeError: Can't convert 'bytes' object to str implicitly Does anyone know what I need to do to make it work with Python31? [code]# create a soundfile in AU … | |
Re: If we would have voted for McCain, he would still not have realized that there is a recession going on. Might just be God's blessing. | |
Airport screening simplified! Provide a booth that each person can step into, that will not X-ray the person, but will detonate any explosive device the person may have on him/her. There would be none of this crap about racial profiling and this method would eliminate a long and expensive trial. | |
I am using Python 3.1.2 What is the best way to get numeric (float or int) user input? | |
Re: [QUOTE=Dan08;1164676]You did not specify what OS you're coding in, but [URL="http://www.daniweb.com/code/snippet230886.html"]this one[/URL] is to get the mouse position in Linux, and apparently in the same thread, Gribouillis gives an answer on how to do it in Windows as well. Also read vagaseat's post, which is interesting. Hope this helps.[/QUOTE]I think … | |
Re: [code]s = """Sign in an Irish pub: We are open from 10 a.m. until 11 p.m. and if you haven't had enough to drink at that hour the management feels that you haven't really been trying.""" fh = open("IrishSign.txt", "w") fh.write(s) fh.close() [/code] | |
Re: You could try something like this example: [code]# create a series of wx.StaticText() labels with a for loop import wx class MyFrame(wx.Frame): def __init__(self, parent, mytitle, pinto_beans): wx.Frame.__init__(self, parent, wx.ID_ANY, mytitle) self.SetBackgroundColour("blue") # use wx.GridSizer(rows, cols, vgap, hgap) for layout gsizer = wx.GridSizer(6, 1, 0, 0) # create a list … | |
Re: The Tkinter GUI toolkit widgets have a very homely look on Windows, the look improves with Linux and particularly the Mac OS. | |
Re: When you call bloodXHealerZZ.buy(gold, arrows, whip, ...) you need to have a value for gold, arrows, whip, and so on. | |
Does anyone have a code example for using the mouse wheel with the Tkinter GUI toolkit handy? | |
Re: Think about all those high paying jobs repairing and reprogramming robots. | |
Re: I understand that the "\r\n" or "\n\r" combination goes back to the old mechanical printers where you had to feed the paper up one line and set the carriage to the beginning margin. I guess this was the standard then. | |
Re: [QUOTE=adam4u;1117916]I didn't understand on what you trying to say, but I'm leaving this problem for "[B][U]professionals people[/U][/B]"[/QUOTE]I would say you need professional help! Leaving your homework problem for others to do for you is cheating! You are cheating the teacher, your fellow students and actually yourself. | |
When I run this code: [code]class C(object): print("Hello from inside class C") [/code]It gives the same result as if I had used this code: [code]print("Hello from inside class C") [/code]However when I use: [code]class B(object): def __init__(self): print("Hello from inside class B") [/code]The class behaves like I had expected. Does … | |
| |
Re: You could do it like that: [code=c]#include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE 50 int main(int argc, char *argv[]) { char string[SIZE], c; int i; // just a test printf("len = %d\n", strlen(string)); // len = 0 printf("Enter a string: "); for (i=0; i < SIZE; i++){ c = … | |
Does anyone use Python on a Windows7 machine? What is your experience? Does it work well? I am thinking about getting a new computer and also start some Python programming. | |
Re: Vagaseat, I tested your code and actually you can just add the two lists this way ... [code=python]def add_lists(a, b): """add lists a and b without changing list a""" return a + b a = ['a', 'b', 'c'] b = [1, 2, 3] c = add_lists(a, b) print( a ) … | |
Re: I think you are talking about function calls. You really don't need to clear the console screen, besides it is too OS specific. Most programmers will tell you that goto is a bad habit. Design your program so that you don't need goto. | |
Re: If you are familiar with C and its printf() function then you can use %s for strings and %0.2f for floats with 2 decimals. In Python like in Ruby you can use %s also for unformatted numbers. In Ruby (much like C): [code=C]printf( "Number: %5.2f, String: %s\n", 1.23456, "hello" ) … | |
Re: I think it is SciTE's output windows that hangs the input. | |
Re: Sounds familiar, but you have to realize that instructors are there to teach some outdated computer language with ever so failing enthusiasm. | |
Re: Good productivity with the c programming language and c++! These are the most active language forums here in Daniweb. Hope to see you there. |
The End.