14,952 Topics

Member Avatar for
Member Avatar for vegaseat

An example how to use Tkinter's OptionMenu() as a combobox to allow one year to be selected from an option list of let's say the past 15 years.

2
1K
Member Avatar for qashnfhkh

don't work this: bg_fon2 = PhotoImage(file='2.GIF') from tkinter import* import random root = Tk() root.geometry("896x626") canv = Canvas(root, height = 626, width = 896) bg_fon = PhotoImage(file='fon.GIF') canv.create_image(0,0,image=bg_fon,anchor='nw') class Fish: image = 0 coor = 0 direct = 0 real_img = 0 obj = 0 canv = 0 def fiish1(): …

Member Avatar for sneekula
0
136
Member Avatar for Amit_25

hii I have a list having m1 m2 m3........ m922 and in each there are a1 a2 a3 a4 are there like m1=a1 a2 a3 a4 a5 a6 m2=a1 a2 a3 a4 a5 a6 m3=a1 a3 a5 a7 a8 a2 etc and i want this as m1=a1 a2 a3 a4 …

Member Avatar for sneekula
0
173
Member Avatar for EdJones

Is this considered good form when writing cross-platform code? #! /usr/bin/env python3 And how about this? if __name__ == "__main__": main() I've reviewed some recent sample snippets and not all of them use the shebang and the conditional main call, so I wasn't sure whether that is still considered good …

Member Avatar for sneekula
0
145
Member Avatar for Ben_8

Hi guys Just started to get into Python so this site seems liek a gtreat resource for hints and tips. Nice to meet you all. Ben

Member Avatar for Gribouillis
1
93
Member Avatar for EdJones

I'm learning python (and programming in general) through Runestone Interactive. What do people think of that site as a place for beginners to learn python? Also, is there any harm in trying to learn perl and web design languages at the same time? I'm concerned about becoming confused.

Member Avatar for Gribouillis
0
149
Member Avatar for ram_10

Hello again :) I'm trying to define a simple "spelling correction" function that takes a string and sees to it that 1) two or more occurrences of the space character is compressed into one, and 2) inserts an extra space after a period if the period is directly followed by …

Member Avatar for Gribouillis
0
307
Member Avatar for matrixdevuk

I am trying to get the following ENUM to work, but it's not working. Any help is appreciated. class Colour(Enum): WHITE = (255,255,255) BLACK = (0,0,0) RED = (215,45,45) BLUE = (45,87,214) YELLOW = (230,223,48) GREEN = (45,194,64) Using it: `Colour.BLACK` Error: /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 "/Users/blooop/main.py" Traceback (most recent call last): File …

Member Avatar for matrixdevuk
0
349
Member Avatar for Johnny Blaz

num = int(input("Enter a number: ")) if num==0 or num<0: continue else: if num > 1: if (num % i) == 0: print(num,"is not a prime number") print(i,"times",num//i,"is",num) break else: print(num,"is a prime number")

Member Avatar for sneekula
0
175
Member Avatar for ram_10

I've to write a function that takes a list of English words and returns a list of Swedish words. For example, {"merry":"god", "christmas":"jul", "and":"och", "happy":gott", "new":"nytt", "year":"år"} used to translate English into Swedish. def translate(a): a = {"merry":"god", "christmas":"jul", "and":"och", "happy":"gott", "new":"nytt", "year":"år"} for k, v in a.iteritems(): print k,v …

Member Avatar for snippsat
0
431
Member Avatar for matrixdevuk

I'm a beginner to Python and I decided to make a permutation finder program. Have fun and don't question the name. :)

Member Avatar for matrixdevuk
0
182
Member Avatar for ram_10

Hello, I'm trying to define a function that takes an integer 'n' and a character and returns a string, 'n' characters long. I'm totally lost and I've nothing. I read in a forum "".join might help. But that too is beyond perceivable for me at this moment. I do have …

Member Avatar for ram_10
0
318
Member Avatar for ram_10

Hello, I've been trying to write a function that takes a value (i.e. a number, string, etc) x and a list of values a, and returns True if x is a member of a, False otherwise. This is the script I could think of. I'm not even sure what might …

Member Avatar for Gribouillis
0
820
Member Avatar for itsthewendigo1111

I"ve been working on this dice game for the past few days. I made sure the game itself worked properly then I added a draw dice function that would show you the dice that were rolled on the canvas. I needed a continue button to make the rest of the …

Member Avatar for itsthewendigo1111
0
260
Member Avatar for tmcclure57

I'm actually helping my wife. She's learning Python. Me? VB.net and C# are my preferance. So I try to help her. All she wants to do is paint a command button, use this to launch another program written in python. I have spent the past few days trying to find …

Member Avatar for vegaseat
0
128
Member Avatar for ram_10

I'm trying to learn scripting in Python. So, I started using an exercise and it had this question for me. Define a function that computes the length of a given list or string. And I can't use the built in function len(). I tried the code below and I can't …

Member Avatar for vegaseat
0
182
Member Avatar for tony75

Hi I installed a different version of Python but how to choose edit with IDLE to open scripts in python 2.7 or python 3.2 on my Windows desktop?

Member Avatar for tony75
0
428
Member Avatar for vegaseat

For those of you who are inquisitive, here is a little Python program to approximate the value of pi to 77 digits. You can easily go further, just change the value n in range(n+1).

Member Avatar for sneekula
0
3K
Member Avatar for MasterHacker110

Recently I've been fooling around with some fun mathmatic (dont knwo if that is even a word) stuff. I recently took on the task of trying to calcualte PI. I have a very simple program in python that does this for me: import math from datetime import datetime top = …

Member Avatar for sneekula
0
345
Member Avatar for nwillis1

I have a computer science project and it has all to do with list and such could someone please help me with it!

Member Avatar for nwillis1
-1
93
Member Avatar for MasterHacker110

I've been messign around with Python a little recently. Though I now want to import one of my .py files into my "main" file, but I get an `"module" object is not callable` error. How do I actually do this then. My files: KeyGenerator.py main.py Code I use to import: …

Member Avatar for MasterHacker110
0
339
Member Avatar for YorkshireSpud

Im personally learning how to program in python though I do know of other languages. Is Python the best to learn off?

Member Avatar for vegaseat
0
278
Member Avatar for kruko

Hello Guys, i am new to python, for a assingment i need to create a game (binary puzzle). im having problems to start with creating the bord, i saw some examples of creating a bord game on this forum but it didnt worked out for me. i want to create …

Member Avatar for Gribouillis
0
525
Member Avatar for vegaseat

This snippet shows you how to animate a dice roll with the Tkinter GUI, useful for many games that require a dice to give a random number from 1 to 6. An interesting use of Tkinter's grid(), grid_forget() and after() functions.

Member Avatar for Jake_6
0
4K
Member Avatar for punna.udaykumar

A series of different parts of sentences will be randomly put together to come up with new interesting sentences. using with Random, Integers, Print, Strings, Breaks, Functions, For, Range

Member Avatar for sneekula
0
481
Member Avatar for ao_py

I am trying to write a program that graphically presents three doors and ask the user to choose the “special” door (randomly selected by the program). If the user correctly chooses the special door, it’s a win. If either of the other two non-special doors is selected, it’s a loss. …

Member Avatar for sneekula
0
888
Member Avatar for dancks

I was testing this in prompt mode: import re def checkurl(url): check = re.match(r'^(:?https?://)?[^\/#?&]+\.[^\/#?&]+.*$',url) if check == None: print “NNOOOOOO!!!!” else: print “YESSSS!!!!!” checkurl("javascript:void(0);") checkurl("/account/general?ru=https%3a%2f%2fwww.bing.com%3a443%2fsearch%3fq%3dukraine%2bcrisis&FORM=SEFD") checkurl("/?FORM=Z9FD1") checkurl("http://choice.microsoft.com") I have no idea why this won't work. Ignore the regex its only supposed to weed out relative paths and fragments of strings. …

Member Avatar for Gribouillis
0
991
Member Avatar for Rahul47

Hello folks, I am currently in 2nd year of Masters Degree and I am expected to develop a project this year from the given topics. I find Command Based text editor like vi fascinating as others were boring. So, here is the project definition. **In this project you are expected …

0
60
Member Avatar for Johnny Blaz
Member Avatar for Florian_2

Hey, guys! Newbie here. =) I try to reverse an image but an error came and i don't know why :/ This is the error: Traceback (most recent call last): File "C:/Users/Florian/Documents/ISN/S10/défi11.py", line 10, in <module> im.putpixel((x,600-y),(p[0],p[1],p[2])) File "C:\Python27\lib\site-packages\PIL\Image.py", line 1267, in putpixel return self.im.putpixel(xy, value) IndexError: image index out …

Member Avatar for vegaseat
0
781

The End.