4,305 Posted Topics
Run two calls to a function simultaneously with this threading @background decorator. | |
Re: Nice approach. However, opening a potentially endless amount of windows is terribly resource demanding. I would suggest to put the mouse info into the title bar of the root window ... [code]# PlottingProgram101.py try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk class FunctionFrame(object): … | |
Re: Got it to work with Windows7, see ... http://www.daniweb.com/software-development/python/code/455571/dragable-frame-using-wxpython-phoenix Project Phoenix is still very alpha. | |
Re: You can also check https://pypi.python.org/pypi/bitarray/ | |
Re: There are a large number of Python programming videos on YouTube. YouTube itself is written using Python. Example ... http://www.youtube.com/watch?v=4Mf0h3HphEA&feature=channel or ... https://www.youtube.com/watch?v=tKTZoB2Vjuk | |
Re: You can do it if the two points are at the ends of the diagonal. See ... http://www.mathsisfun.com/geometry/rectangle.html If you use the Tkinter GUI toolkit, the two points you need to create a rectangle are the upper left corner and lower right corner. | |
Re: Here is a general example that might help ... ''' distance_two_points.py calculate the distance between two points given the coordinates of the points (x1, y1) and (x2, y2) in a 2D system ''' import math def get_distance(x1, y1, x2, y2): ''' returns distance between two points using the pythagorean theorem … | |
Re: I have sported a mustache on and off. Usually a bad cold comes up making a mess of it, so the thing is gone for a while. | |
Re: This will do it ... # tk_KeyLogger.py # show a character key when pressed try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk def key(event): """show just the character key""" if event.keysym == 'Escape': root.destroy() print(event.char) root = tk.Tk() print("Press a key (Escape key … | |
Re: I assume your teacher wants you to use Python code to assign the first three flowers to a sublist. That's where append could be used. | |
Re: You can also use the newer syntax available with Python 2.7 and Python3+ ... sentence = "I now have a total of {} yellow bananas!" for i in range(2, 11): print(sentence.format(i)) | |
Re: Try this ... #!/usr/bin/env python # # @author: Joseph Rex # @website: http://josephrex.me # @repository: http://github.com/bl4ckdu5t/registron # # # import sys, webbrowser from PyQt4 import QtGui, QtCore from ui_registron import Ui_MainWindow try: import pyttsx except ImportError: raise ImportError, "pyttsx module is required for speech features of registron" class Main(QtGui.QMainWindow): """Main … | |
Similiar to the snippet posted at: http://www.daniweb.com/software-development/python/code/449036/display-an-image-from-the-web-tkinter but this time we use PIL to resize the image from the internet keeping its aspect ratio to fit a specific display area/box. | |
The Pyside GUI toolkit (public PyQt) lets you bring up an interactive web page with its QWebView widget. Here is a simple example. | |
Re: You use it when you don't know the exact number of arguments. Simple example ... def average3(*args): """ don't know the exact number of numeric arguments passed prefix * indicates a tuple of variable number of args """ return sum(args)/float(len(args)) print(average3(1, 2, 3, 4, 25)) # 7.0 | |
Re: I would recommend the Pygame Mixer. It works well with Tkinter. In my experience modules like pySFML don't get along with Tkinter's event loop. Here is an example ... ''' tk_pg_playmusic2.py play a sound file with Tkinter using the module pygame works with .wav .ogg .mid or .mp3 sound/music files … | |
Re: Initialize your variables A to L this way: `A = B = C = D = E = F = G = H = I = J = K = L = 0` before you reach your if statements. | |
Re: To expect privacy from the likes of Facebook, Twitter etc. would be silly. | |
Re: You can use the function type() type(object) will give you the type of the specified object. | |
Re: The Python interpreter searches for module "serial" first in the working directory, then in its builtin modules in directory Lib, then in its packages. When it finds a file serial.py in the working directory it will import your code file instead of the module. So please do not name any … | |
Re: Windows binaries are also still available at: http://www.lfd.uci.edu/~gohlke/pythonlibs/ Pyglet uses AVbin for sound, so you could check that: http://avbin.github.io/AVbin/Home/Home.html | |
Re: You could make a list of image file extension and in a loop add these to your file name and check if the file exists. If it does exist load it. See the Python manual under module os | |
Re: Hint ... digits = '123456' size = len(digits) # list of even indexed digits, positions 0,2,4, ... evens = [int(digits[n]) for n in range(0, size, 2)] # list of odd indexed digits odds = [int(digits[n]) for n in range(1, size, 2)] print(evens) # [1, 3, 5] print(odds) # [2, 4, … | |
Re: Sheep + People = Sheeple Sheeple, most of us, are easily programmed particularly by the news media. | |
Re: Wow, lots of options! I myself am more partial to slicing, unless you have to pad your resulting sequence. | |
Re: Most likely this should work ... [code]import mod class cls2(mod.cls1): pass [/code] | |
Re: Somewhat goofy partial code. Could your problems be with the steganography processing? Did you try to put a normal image to test? | |
Re: Line 7 is needlessly duplicated inside the loop at line 18. | |
Re: One more possibility ... from collections import Counter original_list = ["hello", "hi", "hi", "bye", "hi", "bye"] # most_common() gives a list of all (word, freq) tuples sorted by count wordcount = Counter(original_list).most_common() print(wordcount) ''' result ... [('hi', 3), ('bye', 2), ('hello', 1)] ''' | |
| |
Re: Module graphics is a wrapper around Tkinter, so take a look at: http://infohost.nmt.edu/tcc/help/pubs/tkinter/web/create_polygon.html | |
![]() | ![]() |
![]() | Re: My senior year in HS happened in Germany, and I had to sit in the backrow in class because I didn't look German. |
The portable version of Python (versions 2.7 and 3.2 are available) can be run from your hard drive or a flash drive. In many ways this makes your live easier, since a lot of libraries are included already. Also, you can take your code to a friend on a flash … | |
Re: A agree with <M/>, Mickey Mouse needs to be introduced as the real hero of the silly thing. | |
This short Python program calculates Euler's number e, the base of natural logarithms, to a precision of at least 100 digits in this case. To get the precision needed, the Python module decimal is used. The result is compared to a published result. | |
![]() | Re: Only responds when you click on the border of the rectangle. You have to fill the rectangle with eg. white to make the whole shape respond. |
Re: I can imagine walking through a field of flowers to get to my favorite fishing spot wearing ear plugs. | |
Re: You might also consider working with deque (double ended que, pronounced 'deck') from the Python module collections ... from collections import deque mylist = [1,2,3,4,5,6,7] mydeque = deque(mylist) mydeque.rotate(3) print(list(mydeque)) # [5, 6, 7, 1, 2, 3, 4] | |
![]() | Re: I truly frown on folks using Python Shell code for tutorials, it looks ugly, messy, confusing to beginners, and not Pythonic at all! Python prides itself on readable syntax. [B]Thanks for the update and correction![/B] |
Re: Wouldn't it be nice to have the leaders in Washington/London to have an accrediated education? | |
Re: With the Windows OS **PyScripter** (written with Delphi) is my choice. It's fast and gives a lot of helping hints when coding. | |
![]() | |
Re: ''' dict_dynamic101.py create a dictionary dynamically tested with Python27 and Python34 ''' # ---------------------------------------------- # add these few lines near the start of you code import sys # make string input work with Python2 or Python3 if sys.version_info[0] < 3: input = raw_input # ---------------------------------------------- mydict = {} while True: … | |
This simple code shows how to write text with a given font, font size and color using the module pygame ... | |
Re: Maybe this will help ... s = "test01-15.dat" q = s.split('.') print(q) print(q[0]) numeric = "".join(n for n in s.split('.')[0] if n in '0123456789-') print(numeric) print(numeric.split('-')) ''' result ... ['test01-15', 'dat'] test01-15 01-15 ['01', '15'] ''' | |
A Tkinter image button that toggles between an up and down button image. |
The End.