4,305 Posted Topics

Member Avatar for Igor_1
Member Avatar for Johnny Blaz

You have to apply the scrollbar to a particular widget, for example ... ''' ttk_Scrollbar101.py explore the ttk scrollbar widget ''' try: # Python27 import Tkinter as tk import ttk except ImportError: # Python3 import tkinter as tk import tkinter.ttk as ttk root = tk.Tk() scrollbar = ttk.Scrollbar(root) scrollbar.pack(side='right', fill='y') …

Member Avatar for vegaseat
0
4K
Member Avatar for galileo812
Member Avatar for Slavi

About 1 billion Valentine’s Day cards are exchanged each year. This makes it the second largest seasonal card sending time of the year

Member Avatar for vegaseat
0
105
Member Avatar for Reverend Jim

Bright colors, water balloons, lavish gujiyas and melodious songs are the ingredients of perfect Holi. Wish you a very happy and wonderful Holi too. On an unrelated side: I wonder if daylight-savings-time is really saving anything.

Member Avatar for vegaseat
0
61
Member Avatar for Edward_6

Your for loop should look like this ... #declares an empty array (list) called rainfall to #which you can append values with the append method rainfall = [] #for loop to loop from 0 to 11 #remember the 1st element of an array is at subscript 0 for index in …

Member Avatar for vegaseat
0
1K
Member Avatar for Niloofar24

A dictionary in this case would be a list of special names you expect to find. Simply create a text file with each name on its own line that you can read into Python code and form a list or a set (removes any duplicates). You could assume that each …

Member Avatar for iJunkie22
0
380
Member Avatar for Rekt

Here is an example ... # use a Tkinter label as a panel/frame with a background image # (note that Tkinter reads only GIF and PGM/PPM images) # put a button on the background image try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk …

Member Avatar for Rekt
0
3K
Member Avatar for BustACode

I have used module prettytable in the past this way ... ''' prettytable102.py explore module prettytable get prettytable-0.7.2.zip from https://pypi.python.org/pypi/PrettyTable extract the zip file and copy prettytable.py to /Lib/side-packages ''' from prettytable import PrettyTable mylist = [['a', 'b', 'c'], ['a', 'b', 'c'], ['a', 'bbbbbbbbbbbbbbbbbbb', 'c'], ['k', 'k', 'l'], ['a', 'b', …

Member Avatar for vegaseat
0
395
Member Avatar for annndrey

Another example ... http://rowinggolfer.blogspot.com/2010/05/qtreeview-and-qabractitemmodel-example.html

Member Avatar for vegaseat
0
3K
Member Avatar for Taqwasarwar

A simplified version could be ... ''' text_analyze101.py a simple way to analyze text ''' text = '''\ A dad is on his way home a bit late from the office when he realizes that it's his daughter's birthday and he has not bought her a gift. So he stops …

Member Avatar for vegaseat
0
311
Member Avatar for psvmr

Make your life easier by creating a list of (average, name) tuples. That list can be sorted as is. Something like this (stick with the default dictionary as you did before) ... import collections as co # assume this is a string read from a file # showing name:score data …

Member Avatar for vegaseat
0
971
Member Avatar for psvmr

This might be a less complicated approach ... import collections as co # assume this is a string read from a file # showing name:score data on each line data_str = '''\ Charlotte:7 Charlotte:4 Charlotte:3 Chelsea:2 Chelsea:9 Chelsea:5 Jeff:1 Jeff:10''' # convert to a name:score_list default-dictionary ddict = co.defaultdict(list) for …

Member Avatar for vegaseat
0
676
Member Avatar for Reverend Jim
Member Avatar for Niloofar24

An example ... # assume you have this url ... url = "https://www.python.org/downloads/release/python-343/" # the base (scheme + netloc) would be ... base = "https://www.python.org/" # the path would be ... path = "downloads/release/python-343/" # however you want to select one of these paths ... path_list = ["community/", "doc/", "community/jobs/"] …

Member Avatar for Niloofar24
0
833
Member Avatar for vegaseat

Well I done it! Got bored after the holidays and bought a Raspberry Pi credit card sized computer ($35), the least expensive LED TV and a Logitech wireless Keyboard/Mouse combo. The way I ordered the kit it cost almost twice as much, but it came with a good 2.5A powersupply, …

Member Avatar for vegaseat
0
668
Member Avatar for vegaseat

One way to find the shortest distance between a series of surface (x, y) points is to let Python module itertools find the non-repeating combinations of point pairs. Now you can apply the Pythagoras' theorem to find all the distances and the minimum distance.

Member Avatar for gerisam
3
2K
Member Avatar for Akhila_1

Great resource ... https://www.daniweb.com/software-development/c/threads/50370/starting-c-#post234971

Member Avatar for vegaseat
0
154
Member Avatar for Kai_Chang
Member Avatar for vegaseat
0
277
Member Avatar for Niloofar24
Member Avatar for vegaseat
0
421
Member Avatar for Niloofar24
Member Avatar for Niloofar24
Member Avatar for Niloofar24
0
3K
Member Avatar for DragonMastur

megaflo found an error on line 63 I took the time to correct it thanks megaflo

Member Avatar for DragonMastur
0
427
Member Avatar for DragonMastur

You could do this ... def say(msg, optional=""): print(msg) if optional: print(optional) say('hi', 'option') ''' hi option ''' print('-'*12) say('not') ''' not ''' But this is far simpler ... def say(*args): for arg in args: print(arg) say('hi', 'option') ''' hi option ''' print('-'*12) say('not') ''' not '''

Member Avatar for DragonMastur
1
367
Member Avatar for Andrae

Here is one example that might help ... """ tk_treeview101.py see also ... http://stackoverflow.com/questions/16746387/tkinter-treeview-widget """ import os try: # Python2 import Tkinter as tk import ttk except ImportError: # Python3 import tkinter as tk import tkinter.ttk as ttk class DirectoryBrowser(tk.Frame): def __init__(self, master, path): self.path = os.path.abspath(path) self.entries = {"": …

Member Avatar for Andrae
0
20K
Member Avatar for Niloofar24

Error messages are poor with .kv files. One reason I don't like them. Check your log file.

Member Avatar for vegaseat
0
1K
Member Avatar for biocompute

`self.top_right = ScrolledText(self, text=self.text, width=50, height=15)` the instance you get refers to the Frame object and that does not have a 'text' argument. The line `Frame.__init__(self, parent)` in class ScrolledText makes that the instance self You can test it with `print(self.top_right.config()['class'])`

Member Avatar for vegaseat
0
8K
Member Avatar for davidbr

This might give you a hint ... ''' tk_label_lift_lower.py hide and show labels sharing the same grid position with lift and lower ''' try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk def show2(): label1.lower() label2.lift() def show1(): label2.lower() label1.lift() root = tk.Tk() button1 …

Member Avatar for vegaseat
0
387
Member Avatar for Niloofar24

You can only edit within one hour after posting. Try this ... import datetime as dt now = dt.datetime.today() year = now.year # Persian new year march 21 at 2:15:11 pnewy = dt.datetime(year, 3, 21, 2, 15, 11) differ = pnewy - now print("There are {} seconds till Persian New …

Member Avatar for Niloofar24
0
822
Member Avatar for vegaseat
Member Avatar for juanpa_2510
2
2K
Member Avatar for vegaseat

Here we use the eval() function as the backbone of a simple calculator. One table is used for the display. A second table holds the buttons for the keypad. The whole thing forms an attractive looking calculator. To test it, simply paste the code into an editor like notepad and …

Member Avatar for diafol
1
2K
Member Avatar for RobertHDD
Member Avatar for ZZMike
Member Avatar for Niloofar24

Something like this ... mylist = [2,4,4] number = int("".join(str(n) for n in mylist)) print(number, type(number))

Member Avatar for vegaseat
0
299
Member Avatar for vegaseat
Member Avatar for MustafaScript

The Python manual at https://www.python.org/doc/ contains a tutorial you may play with. Use the IDLE IDE that comes with your Python installation and start typing the code and try it out. Python makes it easy to experiment. John Guttag's video lectures are excellent but a little heavy on Computer Science …

Member Avatar for fonzali
0
417
Member Avatar for Niloofar24

Not sure why you want to do this, but one way is to build a ringbuffer ... import collections def ringbuffer_append(item, dq=collections.deque(maxlen=3)): ''' mimics a ringbuffer of length 3 you can change maxlen to your needs ''' dq.append(item) return list(dq) # testing mylist = ringbuffer_append('red') print(mylist) mylist = ringbuffer_append('green') print(mylist) …

Member Avatar for Niloofar24
0
623
Member Avatar for Niloofar24
Member Avatar for Niloofar24

mylist = [6, '/', 3, '+', 9, '+', 8, '+', 1, '/', 2] print(mylist) # replace mylist with an empty list mylist = [] print(mylist) # --> [] mylist = [6, '/', 3, '+', 9, '+', 8, '+', 1, '/', 2] # delete part of a list, keep the first …

Member Avatar for Niloofar24
0
276
Member Avatar for Cup of Squirrel

The correct answer is from [url]http://www.daniweb.com/techtalkforums/thread20774.html[/url] [code] # raw_input() reads every input as a string # then it's up to you to process the string str1 = raw_input("Enter anything:") print "raw_input =", str1 # input() actually uses raw_input() and then tries to # convert the input data to a number …

Member Avatar for Jason_15
1
18K
Member Avatar for Odyssey2001
Member Avatar for Odyssey2001
0
606
Member Avatar for Santanu.Das

Ruby skills are not much in demand. My prediction is that Java demand will slowly fizzle and will be replaced by a combination of Python and C++. Python for the speed of development, and C++ for the speed of code and its large libraries. Python and C++ work very well …

Member Avatar for vegaseat
0
274
Member Avatar for iamthwee
Re: Java

Java is very well entrenched in the CS teaching apparatus. It will take a while for this to modernize.

Member Avatar for iamthwee
0
494
Member Avatar for 00Gambit
Member Avatar for ~s.o.s~
0
409
Member Avatar for Niloofar24

I think it's called an OptionMenu ... ''' tk_OptionMenu1.py using Tkinter's Optionmenu() as a combobox allows one item to be selected use a button to show selection ''' try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk def ok(): sf = "value is %s" …

Member Avatar for vegaseat
0
6K
Member Avatar for 00Gambit

You need to double click on the code field which will highlight the code. Now you can copy and paste it to an IDE editor. The code works. Initially you may want to tell the user to click add. Once you have more than 2 balls collision response will be …

Member Avatar for vegaseat
0
176
Member Avatar for ebaum2112

Read the comments ... [code]# draw a checker board with Python module turtle import turtle as myTurtle def drawCheckerBoard(myTurtle, sideLength): myTurtle.speed('fastest') # turtle by default starts at (x=0, y=0) center of a (450x550) window # to pick another center lift the pen up then move # to the left -x …

Member Avatar for ilona.lizard
0
225
Member Avatar for johnny blaz97

Also, when you see very repetitive code, then a function or a loop comes to mind.

Member Avatar for vegaseat
0
1K
Member Avatar for iamthwee

For small projects in Python I use Tkinter quite a bit. Generally I haven't used **tkdocs** for a reference because the information is scatterd amongst so many languages. The Python manual contains Ykinter and is easier to use.

Member Avatar for vegaseat
0
146
Member Avatar for MustafaScript

Highlight your code and press **Code** on the bar above to preserve your indentations.

Member Avatar for vegaseat
0
2K

The End.