Sponsored Content
Top Forums Shell Programming and Scripting [Python]StringVar() Class String processing Post 302572392 by animesharma on Wednesday 9th of November 2011 11:16:34 PM
Old 11-10-2011
[Python]StringVar() Class String processing

I have a requirement where I collect inputs from entry widget in gui(via variables a,b,c) and then output a string like this: -a a -b b -c c.

Hence if I have given a=1 b=2 c=3, The output string is --> -a 1 -b 2 -c 3
or if I have given a=1 b=2 (c left blank) then the output is --> -a 1 -b 2

As of now, I am able to get the values a,b,c in a stringvar class variable, but I am struggling to generate the
desired output string


Code:
from tkinter import *
from tkinter import ttk

def calculate(*args):
    A=str(a.get())  
    B=str(b.get()) 
    C=str(c.get())

    #out.set(A+" "+B+" "+C)





root = Tk()
root.title("Sample nruntest GUI")
mainframe = ttk.Frame(root)
mainframe.grid(column=0,row=1)
mainframe.columnconfigure(0,weight=1)
mainframe.rowconfigure(0,weight=1)
mainframe['relief'] = 'groove'
mainframe['padding'] = (5,5)
mainframe['borderwidth'] = 2
#
a=StringVar()
b=StringVar()
c=StringVar()
out=StringVar()
#
al=ttk.Label(root,text="A").grid(column=0,row=0,sticky=W)
bl=ttk.Label(root,text="B").grid(column=0,row=1,sticky=W)
cl=ttk.Label(root,text="C").grid(column=0,row=2,sticky=W)
out_l=ttk.Label(root,text="Out").grid(column=0,row=3,sticky=W)
ae=ttk.Entry(root,width=10,textvariable=a).grid(column=1,row=0,sticky=E)
be=ttk.Entry(root,width=10,textvariable=b).grid(column=1,row=1,sticky=E)
ce=ttk.Entry(root,width=10,textvariable=c).grid(column=1,row=2,sticky=E)
out_e=ttk.Entry(root,width=10,textvariable=out).grid(column=1,row=3,sticky=E)

button = ttk.Button(root,text="hello",command=calculate).grid(column=0,row=4)
root.mainloop()


Last edited by animesharma; 11-10-2011 at 12:29 AM..
 

6 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Get pointer for existing device class (struct class) in Linux kernel module

Hi all! I am trying to register a device in an existing device class, but I am having trouble getting the pointer to an existing class. I can create a class in a module, get the pointer to it and then use it to register the device with: *cl = class_create(THIS_MODULE, className);... (0 Replies)
Discussion started by: hdaniel@ualg.pt
0 Replies

2. Programming

C++ string class design and implementation

Hi, I am designing the look-alike C++ string class: #include <iostream> #include <cstring> #include <exception> #include <new> #define ALLOC(N) (char*) new char #define DELETE(P) delete ((char*)(P)) class String { public: // conversions: to C-like type char operator const... (2 Replies)
Discussion started by: royalibrahim
2 Replies

3. Programming

Size of Derived class, upon virtual base class inheritance

I have the two class definition as follows. class A { public: int a; }; class B : virtual public A{ }; The size of class A is shown as 4, and size of class B is shown as 16. Why is this effect ?. (2 Replies)
Discussion started by: techmonk
2 Replies

4. Shell Programming and Scripting

Match string against character class in bash

Hello, I want to check whether string has only numeric characters. The following code doesn't work for me #!/usr/local/bin/bash if ]]; then echo "true" else echo "False" fi # ./yyy '346' False # ./yyy 'aaa' False I'm searching for solution using character classes, not regex.... (5 Replies)
Discussion started by: urello
5 Replies

5. Shell Programming and Scripting

Kbd input processing with python

Hi, I'm new to python, and I work on a little program fpr my rapsberry pi. This scenario here is a little Midi sysex app for my Roland D-50 Synthesizer. With an usb attached number keypad I can type numbers from 0 to 9 and the referenced Midi sysex file would be send out to my Roland D-50... (1 Reply)
Discussion started by: sdohn
1 Replies

6. Programming

Python (seleniumrequests)Class, Constructor, Method Not Working

Newbie question. I created a class: class WP(seleniumrequests.PhantomJS): def __init__(self, wpurl='https://blah.org/download/release-archive/', bwppurl='https://blah.org/plugins/browse/popular/'): self.wp=wpurl ... (5 Replies)
Discussion started by: metallica1973
5 Replies
ttk::sizegrip(n)						 Tk Themed Widget						  ttk::sizegrip(n)

__________________________________________________________________________________________________________________________________________________

NAME
ttk::sizegrip - Bottom-right corner resize widget SYNOPSIS
ttk::sizegrip pathName ?options? _________________________________________________________________ DESCRIPTION
A ttk::sizegrip widget (also known as a grow box) allows the user to resize the containing toplevel window by pressing and dragging the grip. STANDARD OPTIONS
-class -cursor -state -style -takefocus See the ttk_widget manual entry for details on the standard options. WIDGET COMMAND
Sizegrip widgets support the standard cget, configure, identify, instate, and state methods. No other widget methods are used. PLATFORM-SPECIFIC NOTES On Mac OSX, toplevel windows automatically include a built-in size grip by default. Adding a ttk::sizegrip there is harmless, since the built-in grip will just mask the widget. EXAMPLES
Using pack: pack [ttk::frame $top.statusbar] -side bottom -fill x pack [ttk::sizegrip $top.statusbar.grip] -side right -anchor se Using grid: grid [ttk::sizegrip $top.statusbar.grip] -row $lastRow -column $lastColumn -sticky se # ... optional: add vertical scrollbar in $lastColumn, # ... optional: add horizontal scrollbar in $lastRow BUGS
If the containing toplevel's position was specified relative to the right or bottom of the screen (e.g., "wm geometry ... wxh-x-y" instead of "wm geometry ... wxh+x+y"), the sizegrip widget will not resize the window. ttk::sizegrip widgets only support "southeast" resizing. SEE ALSO
ttk::widget(n) KEYWORDS
widget, sizegrip, grow box Tk 8.5 ttk::sizegrip(n)
All times are GMT -4. The time now is 09:21 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy