407 Posted Topics
Re: Python's double-ended queue called deque in module collections has a method rotate() that is ideal for that sort of thing. | |
Re: If pygame and tkinter have event loops, then you have to use threading to separate them. | |
Re: An ordered dictionary remembers its insertion order. | |
Re: This might give you some important hints about GUI programming: ''' tk_Entry_input101.py explore multiple tkinter Entry() for inputs note: Python2 uses Tkinter Python3 uses tkinter ''' # Python3 import tkinter as tk def name_action(event): person = enter1.get().capitalize() sf = "Hello {}. How are you today?".format(person) result['text'] = sf # now … | |
Re: You might have to use the setText() method like this: # blank out old text first correctMessage.setText(" ") correctMessage.draw(self.win) correctMessage.setText("Correct!") correctMessage.draw(self.win) | |
Re: Here is a typical example: ''' tk_BGImage1.py use a Tkinter label as a panel/frame with a background image (note that Tkinter without PIL reads only GIF and PGM/PPM images) modified from a vegaseat example ''' try: # for Python2 import Tkinter as tk except ImportError: # for Python3 import tkinter … | |
Re: This might help: # use opacity alpha values from 0.0 to 1.0 # opacity/tranparency applies to image and root frame root.wm_attributes('-alpha', 0.7) | |
Re: destroy() is used to destroy a particular window in a multiwindow program you have to give all the Tk windows a unique name | |
Re: A RAD GUI Building IDE for Python using wxPython: http://sourceforge.net/projects/boa-constructor/ See also: http://www.daniweb.com/software-development/python/threads/20774/starting-python/6#post400296 If you use Python3 you can go with the Eric5 IDE. That program is free and uses the powerful PyQT GUI toolkit. That in turn comes with a designer (form builder). Google for Eric5 PyQT4 free from: … | |
Re: Here is a hint ... ''' filename_list_given_dir1.py use module glob to list all the filenames of .jpg files or any extension(s) you specify in a given directory ''' import glob import os # all files (split off file names) in a given directory directory = "C:/Temp/*.jpg" # this would give … | |
Re: Not sure what's going on, but DaniWeb is loaded with popups today! | |
Re: [QUOTE=efmesch;504817]I won't say it's the only definition, but vitally important aspects of the concept are: Real love is long-term mutual commitment and includes and infinite amount of the ability to forgive.[/QUOTE]"Love is infinite forgiving" Sounds real nice! You must be a person of much experience efmesch. | |
![]() | Re: Here you go: ''' wx_colourdb_show1.py show the colours in wxPython's wx.lib.colourdb the database has 630 named colors use wx.lib.scrolledpanel.ScrolledPanel and wx.GridSizer to show the colours and their names Python 2.7.5 ''' import wx import wx.lib.scrolledpanel # note the goofy english spelling import wx.lib.colourdb class MyScrolledPanel(wx.lib.scrolledpanel.ScrolledPanel): def __init__(self, parent): # make … ![]() |
Re: Should be: if (temperature > 35) { // do something } else if (temperature >= 27) { // do something else } else { // do something else } | |
Re: All those people trying to cover up their wrinkles. I would start sellling cosmetics! | |
Re: There ar three basic ways to load and display an image with Tkinter: 1) from an image file you have, GIF is native any other file format needs PIL see tk example in: http://www.daniweb.com/software-development/python/threads/191210/python-gui-programming#post866067 2) from a base64 encoded image string pick an example from: http://www.daniweb.com/software-development/python/code/440446/python2python3-base64-encoded-image 3) from a web … | |
Re: The news just reported that the Porsche these dummkopfs were driving went over 100 miles/hour in a residential area. | |
Re: You have to consider that a good chunk of the $634 million contract price goes back to the polititians that made it possible that you got the contract. Not sure what the going cut in Washington is these days. | |
Re: Is there a way to make the print any smaller so I really can't read it? | |
Re: Looks like method getenv(self, tag_str) is missing in the code. | |
Re: I take my iPad with me on the train, but don't commute during typical rush hour. | |
Re: This should work: def is_string_in_list(mystring, mylist): for c in mystring: if c not in mylist: return False return True # short test mylist = ['a', 'b', 'c'] mystring = 'acb' print(is_string_in_list(mystring, mylist)) # True mystring = 'afc' print(is_string_in_list(mystring, mylist)) # False | |
Re: The first line in your function is `count=0` so that is what will happen each time you call the function. If you use it as an argument, then it is only used when the function is defined, as a default value. A temporary test print is your friend! | |
Re: Study this in detail: http://www.pygame.org/docs/tut/camera/CameraIntro.html I think it supports only certain cameras. | |
Re: Looks like your teacher wants a more complex input in function main() like this: # endless loop with exit condition while True: print("Enter tution rate, current year, target year") print("in the form nnnnn.nn xxxx yyyy") data = raw_input("? ") current, thisYear, targetYear = data.split() current = float(current) thisYear = int(thisYear) … | |
Re: This basic class example should send you on your Python way: class Rectangle: # class constructor # supply it with initial length and width values # self refers to the instance def __init__(self, length, width): self.width = width self.length = length def setLength(self, length): self.length = length def show(self): print("rectangle … | |
Re: Another video series: http://www.youtube.com/user/ryanmshea or: http://www.youtube.com/playlist?list=PLEA1FEF17E1E5C0DA | |
Re: Syria was a French colony for 20 years and the occupation was brutal. Strange that these are the only folks who want to join us in bombing the place. | |
Re: Since you are already using Python3, This would simplify it somewhat: def get_int(prompt="Enter an integer: "): """this function will loop until an integer is entered""" while True: try: # return breaks out of the endless while loop return int(input(prompt)) except ValueError: print("Try again, value entered was not an integer.") width … | |
Re: I read somewhere that Google gets 15 thousand job applications a week. So good luck! | |
Re: More modern: ''' tk_button_toggle6.py using itertools.cycle() to create a Tkinter toggle button ''' import itertools try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk def toggle(icycle=itertools.cycle([False, True])): state = next(icycle) t_btn['text'] = str(state) root = tk.Tk() t_btn = tk.Button(text="True", width=12, command=toggle) t_btn.pack(pady=5) root.mainloop() | |
Re: The Washington Post reports that the NSA has done many thousands of illegal snooping without the approval of the rubberstamp courts. Is the system out of control? By the time people are scared to say anything against their rulers, it's too late! | |
Re: There are a lot more Java jobs since it takes more person hours to develop programs with Java. As I understand it, most apps are written with Java. However, there is a lot of garbage out there. | |
Re: I think the problem is: isnumeric for what purpose? | |
Re: You might want to use a drone to crash other drones that pester you. | |
Re: To me Python has always been the quick tool to develop ideas. A bloated cumbersome IDE does not help. | |
Re: Do not use str for a string variable name | |
Re: If the user enters an integer, your program should be smart enough to use it as a float. I also understood you didn't want to use "try except" error handling. Quoting: > ... but how it will be done without using "try and exception" | |
Re: Moral: "Don't assume if a program does not work, that it is fault of the computer or the language." | |
Re: See: http://stackoverflow.com/questions/17079934/opening-files-with-pydbg-while-application-is-running | |
Re: Another option is to use Tkinter's simple dialogs for user input, and to some extent output too: # use Tkinter's simple dialogs (pop-up) to ask for input # minvalue and maxvalue are optional try: # for Python2 import Tkinter as tk import tkSimpleDialog as tksd except ImportError: # for Python3 … | |
Re: Check out Python module difflib | |
Re: Thanks for pointing that pywin32 needs to be installed too! | |
Re: Thanks Henri, module pyttsx is somewhat complicated to install, but works well. Doesn't seem to work with Python3? | |
Re: Java has been around for about 20 years and they still correct their bugs about every week. |
The End.