4,305 Posted Topics
Re: To append seltext to existing text in the entry widget simply use: E1.insert(END, seltext) | |
Re: [quote=jbennet;369819]ours is like 94 - 99 pence per gallon (thats about $1.90ish)[/quote] Per gallon? My English relatives tell me it is more like US $7 ++ per gallon. | |
Re: Hi Jeff, what is broken in the "Toggle Plain Text" option? | |
Re: To hide or show a wxPython widget you can use something like ... [code]button1.Hide() # make button invisible button1.Show() # show it again [/code] | |
Re: When you run your Tkinter program, you are running a Windows GUI program and the eventloop of that program will intercept all keyboard and mouse events. Why can't you let the user enter the answers into a Text widget? It is very hard to mix console and windows programs. | |
Re: It would be simple to use the capture option that comes with many image viewers like XnView (nice and free). For another potential solution look at: [URL]http://www.daniweb.com/code/snippet705.html[/URL] | |
Re: I am not quite sure what you are trying to do, but your widget placements are off the map. It looks to me like you are trying to make a console type game with a GUI. In that case I would recommend to use the text widget and scroll that. … | |
Re: This depends on which browser you are using. Netscape keeps the cookies in a text file, and IE in a directory as individual files. Take a look at: [URL]http://www.cookiecentral.com/faq/[/URL] For an example how to explore IE cookies see: [URL]http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/80443[/URL] | |
Re: Take a look at this Python code snippet: [URL]http://www.daniweb.com/code/snippet467.html[/URL] | |
Re: If I understand this right you want something similar to this ... [code=python]# take a random hand of cards where each card is identified by # string 'rank suit' and sort by rank and suit def cards_str2tup(cards): """ convert each card 'rank suit' string to a (suit, rank) tuple where … | |
Re: Ruby looks a lot like Python. The Python syntax, at least to me, looks cleaner. I do like the help file that comes with Ruby. | |
Re: You got to let us know a little more, what module are you using, pygame, tkinter, gtk, wx? | |
Re: My suggestion is to break this monster down to smaller parts and test each part before you assemble it all. Get familiar with GUI programming, classes, callbacks, functions and so on. At first glance there are a lot of mistakes. For instance this line: printrec= Button(a, text ="PRINT LIST",command=project.printfile(thelist1)) has … | |
Re: Please use the [B][noparse][code=python][/noparse][/B] and [B][noparse][/code][/noparse][/B] tag pair to enclose your python code. Good grief, you are almost there! You have ... [code=python]mylist = [2, 4, 6, 8, 10, 12, 14, 16, 18, 10] sum = 0 for num in mylist: sum = sum + num print "The sum is", … | |
Re: Your program may be a good candidate for place(), see the Python/Tkinter code snippet at: [URL]http://www.daniweb.com/code/snippet693.html[/URL] | |
Re: If you use Tkinter there are over a million different colors to pick from. [code=python]# select a color from the color dialog and color the root window # there are also a few named colors Tkinter can use directly: # "white", "black", "red", "green", "blue", "cyan", "yellow", "magenta" from Tkinter … | |
Re: Thanks Jeff! I had made myself a note when using PIL and Tkinter not to use 'from Tkinter import *' but the simple 'import Tkinter as tk' to avoid namespace conflicts with Image. Your other observations are rather astute! | |
Re: Don't use a label, use a text widget ... [code=python]# just a way to display long text import Tkinter as tk def display(data): """creates a text display area with a vertical scrollbar""" scrollbar = tk.Scrollbar(root) text1 = tk.Text(root, yscrollcommand=scrollbar.set) text1.insert(0.0, data) scrollbar.config(command=text1.yview) scrollbar.pack(side='right', fill='y') text1.pack(side='left', expand=0, fill='both') root = tk.Tk() … | |
Re: Under tools there is an update option, makes sure you have at least version 1.8.0.0 of Pyscripter. The older versions had trouble with wxPython, not quite sure why, since Pyscripter is written with Delphi. | |
Did you know C# has its own scripting language based on Lisp, here is an example ... [code];;; Scripting a 'C#'' GUI with Lsharp, free from [URL="http://www.lsharp.org"]www.lsharp.org[/URL] (reference "System.Windows.Forms") (reference "System.Drawing") (using "System.Drawing") (using "System.Windows.Forms") ;; Create a form (= form (new System.Windows.Forms.Form)) (set_text form "Hello from Lsharp") ;; Create … | |
Re: In a GUI print and input are replaced by label and entry components. Here is a typical example ... [code=python]# a simple Tkinter number guessing game from Tkinter import * import random def click(): # get the number in the entry area num = int(enter1.get()) # check it out if … | |
Re: [quote=woooee;337419]Try a="itself ‘a parody’."[/quote] The problem is that US keyboards don't have a left and right singlequote character, so you need to escape the hex value of the character. This works in Python ... [code=python]x = 'itself \x91a parody\x92.' print x # itself ‘a parody’. [/code]If you feed string x … | |
Re: Here is one book I would not recommend: "C# How To Program" by Deitel I wasted $85 on this thing. It is uninformative and the index is written by a 4 year old! | |
Re: In your code tag [code = python] don't use any spaces! It's [code=python] | |
Re: Please wrap your code in code tags, so it preserves the indentations and looks somwhat like Python code! See: [URL]http://www.daniweb.com/techtalkforums/announcement114-3.html[/URL] For Python code on Daniweb: Please use the [b][noparse][code=python][/noparse][/b] and [b][noparse][/code][/noparse][/b] tag pair to enclose your python code. Note, no spaces in [code=python] | |
Re: For me using Boa is simply too frustrating. I rather create a template and use that to flesh out into a program. Here is a template that does something similar to what you want, experiment with it. [code=python]# the wxChoice() widget, a simple dropdown box # select a color choice … | |
Re: It depends how sophisticated you want to get. If it is a simple text based console program, you can make an array of strings. Each string contains let's say eighty characters, all spaces but for one asterisk. It will be your genius to place the lonely asterisk at the right … | |
Re: You mean something like this ... [code=python]def kilo(): kilometers = input("What is the distance in kilometers?:") return kilometers def miles(km): """calculates miles from kilometers km""" miles = km * .62 return miles def main(): print "This program converts kilometers to miles." km = kilo() print miles(km) main() [/code] | |
Re: The wx.ScrolledWindow class manages scrolling for its client area, transforming the coordinates according to the scrollbar positions, and setting the scroll positions, thumb sizes and ranges according to the area in view. There is also the wx.lib.scrolledpanel.ScrolledPanel() widget that expands on wx.ScrolledWindow. | |
Re: Yes linux, that would be the simplest way to do it! Python allows you to pass functions as arguments to a function. This code might give you more flexibility ... [code=python]# giving a Tkinter Button command two (or multiple) functions to run import Tkinter as tk def do_two(s, f1, f2): … | |
Re: The Python language itself depends heavily on highspeed mappings called dictionaries. Strings are used as keys and have to be immutable objects. Jeff is right, it takes a while to sink in. You actually should store your result in a variable ... [code=python]from string import Template s = Template('$who has … | |
Re: I think you are talking about a bread and butter item of Python. Your child-script is called a module and you import into your parent-script. Take a look at: [URL]http://www.daniweb.com/techtalkforums/post287241-87.html[/URL] | |
Re: Note that the images are objects not strings, so you have to do this ... [code=python]import Tkinter import random import Image, ImageTk def changeImage(): global listOfImages im = listOfImages[random.randint(0,8)] box1Label.configure(image=im) top = Tkinter.Tk() r7 = ImageTk.PhotoImage(file="gfx/r7.jpg") b7 = ImageTk.PhotoImage(file="gfx/b7.jpg") A = ImageTk.PhotoImage(file="gfx/A.jpg") B = ImageTk.PhotoImage(file="gfx/B.jpg") C = ImageTk.PhotoImage(file="gfx/C.jpg") f = … | |
Re: If you don't want to change your original function you can attach a decorator just above the function as shown ... [code=python]# intercept a wrong data type with a function decorator def require_num(func): """decorator to check if a function argument is a number""" def wrapper (arg): if type(arg) in (int, … | |
Re: I don't use IDLE much, but mostly the DrPython IDE. I know IDLE has some problems with firewall settings, could that be it? | |
Re: My new machine has Windows Vista OS and I can't get Tkinter to work, but wxPython works fine ... [code=python]# create a background image on a wxPython panel # and show a button on top of the image import wx class Panel1(wx.Panel): """class Panel1 creates a panel with an image … | |
Re: Somehow ypos and xpos are established but never used. What are your error messages? | |
Re: I used a similar library for Delphi and it worked well. Here is the C/C++ counterpart. "Windows Std Serial Comm Lib for C/C++" (includes XP), a shareware download from: [URL]http://www.sharewareconnection.com/windows-std-serial-comm-lib-for-c-c-.htm[/URL] | |
Re: With mutable objects like lists and dictionaries you have to be careful with direct assignments. Yes, it makes a copy, but a copy that shares the same address. [code=python]>>> a = [1,2,3] # this makes b an alias of a, they both share the same address >>> b = a … | |
Re: Do you want to do this in C or C++. For C++ see the code snippet at: [url]http://www.daniweb.com/code/snippet225.html[/url] With C you have to slug it out in the trenches! Not too hard to do, just labor! A word can end with a space, tab, period, comma, semicolon, newline, ? or … | |
Re: You need to give us the full code, or we won't know where 'plot' is coming from. | |
Re: wxPython comes in an ansi and a unicode version, you need to install the unicode version. | |
Re: Searching our own Python snippet section there are several hits under 'wordcount' and word frequency. These snippets are probably more complex than what you need, so here is a very simple way to do it ... [code=python]# Chinese wisdom ... str1 = """Man who run in front of car, get … | |
Re: Python.h is normally in a subfolder '\include' in your Python folder. | |
Re: Python's floating point precision is that of a double in C (about 16 digits). For higher precision you can use the Python module decimal. | |
Re: Just in case others are interested, to exit a program use ... [code]import sys sys.exit() [/code]or easier ... [code]raise SystemExit [/code] | |
Re: Please use the [B][noparse][code=python][/noparse][/B] and [B][noparse][/code][/noparse][/B] tag pair to enclose your python code. Otherwise you lose all your indentations and you code becomes unusable! With the housekeeping out of the way, "Welcome to the Python forum!" | |
Re: [quote=jbennet;312794]yeah i would like to point out now that nothing you make in .NET will run on linux easialy if at all[/quote]There is an open source project called MONO that allows .NET stuff to be run on the Linux operating system. I think the name MONO came from the effort … |
The End.