473,416 Members | 1,733 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Some advice needed on an Tkinter app that I try to write

Hi,

Armed with Programming Python 3rd Edition and Learning Python 2nd
edition I try to write an application which I at first thought was
simple, at least until I was finished with the GUI and then wanted to
start putting some data into it.

As you will see, the program is not yet finished but I post what I have
so far.

It will read a spice file and extract the interfaces to the
subcircuits. The purpose of the program is to assign the interface pins
to sides of a rectangular box symbol which will represent the
subcircuit in a graphical design tool dedicated for electronics design
(Cadence to be precise) The output of the tool will be a lisp like text
format which can be read into that tool and there the actual generation
of the graphical symbol will take place.

The name of the subcircuits will be shown in the ScrolledList Widget.
When the user click on one of the entries of that widget, the pins of
the interface will be shown in the AssignList widget. (I have not
managed this, yet) If the user select any of the ScrolledList entries
(Single selection) the current setting is shown in the other widgets.
This implies that the user can move from one subcircuit to the next
before all pins have been placed. (I need some kind of an in-memory
database to take care of the data)

In the AssignList widget, either the user can select one or more
entries (extended selection) and press one of the four buttons
left,top,bottom,right and the pins will be moved to the respective
PinList widget. This process goes on until all the pins have been
assigned a side. When a pin is moved from the AssignList to one of the
PinList widgets, the pin is deleted from the AssignList.

If the user by accident move a pin to the wrong side, he can select the
wrongly placed pin and press the "Move here" button under the proper
PinList widget. Pins will always be placed at the bottom of a PinList.
This will make a rudimentary rearrange possible: If the Move Here
button of the same PinList widget is pressed, the selected pins
(extended selection) are moved to the bottom. (in an extended selection
the highest index will be moved first)

When I have come this far, I will add a menu line with options to save
the whole database to the text format which I can read into Cadence.

My biggest problem is probably that I have to implement a model view
controller but none of the books cover how to do this in Python. I have
tried to search on the web with google and find a lot of descriptions,
but so far nothing that make me more clever.

The problem which I have been chewing on the whole weekend is how to
tell the AssignList to load the pins belonging to the subcircuit
selected in ScrolledList.

Any ideas?
--
Svenn

#!/bin/env python

from Tkinter import *

class ScrolledList(Frame):
def __init__(self, data, parent=None):
Frame.__init__(self, parent)
self.pack(expand=YES, fill=BOTH)
self.makeWidgets(data)

def handleList(self, event):
index = self.listbox.curselection()
label = self.listbox.get(index)
self.listbox.insert(END, label)
self.runCommand(label)

def makeWidgets(self, options):
sbar = Scrollbar(self)
list = Listbox(self, relief=SUNKEN)
sbar.config(command=list.yview)
list.config(yscrollcommand=sbar.set)
sbar.pack(side=RIGHT, fill=Y)
list.pack(side=LEFT, expand=YES, fill=BOTH)
pos=0
for label in options:
list.insert(pos,label)
pos += 1
list.bind('<<ListboxSelect>>', self.handleList)
list.bind('<Double-1>', self.handleList)
list.configure(selectmode=EXTENDED)
self.listbox = list

def runCommand(self, selection):
print 'You selected in: ', self
g_from=self

#----------------------------------------------------------
# A Widget to set some pins
#----------------------------------------------------------
class PinList(Frame):
def __init__(self, text="", parent=None):
Frame.__init__(self, parent)
self.pack(expand=YES, fill=BOTH)
self.makeWidgets(text)
def makeWidgets(self, text):
frame = LabelFrame(self, text=text)
list = Listbox(frame, relief=SUNKEN)
sbar = Scrollbar(frame)
button = Button(frame, text='Move here',
command=self.handleList)
sbar.config(command=list.yview)
list.config(yscrollcommand=sbar.set)
frame.pack(side=LEFT, expand=YES, fill=BOTH)
button.grid(column=0, row=1, sticky=E+W)
list.grid(column=0, row=0, sticky=N+S+E+W)
sbar.grid(column=1, row=0, sticky=N+S)
frame.columnconfigure(0, weight=1)
frame.rowconfigure(0, weight=1)
list.bind('<<ListboxSelect>>', self.handleList)
self.listbox = list
def handleList(self, event):
index = self.listbox.curselection()
label = self.listbox.get(index)
def runCommand(self, selection):
print 'You selected: ', selection

class AssignList(Frame):
def __init__(self, data, parent=None):
Frame.__init__(self, parent)
self.pack(expand=YES, fill=BOTH)
self.makeWidgets()
def makeWidgets(self):
b1 = Button(self,
text="L\ne\nf\nt").grid(column=0, row=1, sticky=N+S)
b2 = Button(self,
text="Top").grid(column=1, row=0, sticky=E+W)
b3 = Button(self,
text="Bottom").grid(column=1, row=2, sticky=E+W)
b4 = Button(self,
text="R\ni\ng\nh\nt").grid(column=2, row=1, sticky=N+S)
l1 = Listbox(self).grid(column=1, row=1, sticky=N+S+E+W)
self.columnconfigure(1, weight=1)
self.rowconfigure(1, weight=1)
self.listbox = l1

# Test variables ------------------------------------------

data = {'buffer' : ['output', 'input', 'avdd', 'avss'],
'inverter': ['outputx', 'input', 'avdd', 'agnd'],
'adc' : ['d3', 'd2', 'd1', 'd0', 'anin', 'aref', 'clk']}

# ---------------------------------------------------------

#root = Tk()
class AppGui(Frame):
def __init__(self,parent=None):
Frame.__init__(self,parent=None)
self.pack(expand=YES, fill=BOTH)
self.make_widgets()
def make_widgets(self):
raw = LabelFrame(self, text="The Raw SUBCKT Data")
raw.pack(fill="both", expand="yes")

raw_pane = PanedWindow(raw)
raw_pane.pack(fill="both", expand="yes")

subckt_frame = LabelFrame(raw_pane, text="The SUBCKT Entities")
subckt_frame.pack(side="left", fill="both", expand="yes")
subckt_list = ScrolledList(data, subckt_frame)
subckt_list.pack(side="left", fill="both", expand="yes")

assign_frame = LabelFrame(raw_pane, text="Assign pins to sides")
assign_frame.pack(side="left", fill="both", expand="yes")
assign_list = AssignList(data, assign_frame)
assign_list.pack(side="left", fill="both", expand="yes")

raw_pane.add(subckt_frame)
raw_pane.add(assign_frame)

pins = LabelFrame(self, text="The assigned pins")
pins.pack(fill="both", expand="yes")
left_frame = PinList(parent=pins, text="Left side")
left_frame.pack(side="left", fill="both", expand="yes")
top_frame = PinList(parent=pins, text="Top side")
top_frame.pack(side="left", fill="both", expand="yes")
bottom_frame = PinList(parent=pins, text="Bottom side")
bottom_frame.pack(side="left", fill="both", expand="yes")
right_frame = PinList(parent=pins, text="Right side")
right_frame.pack(side="left", fill="both", expand="yes")

AppGui().mainloop()

Oct 8 '06 #1
0 1400

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like...
0
by: Mark 'Kamikaze' Hughes | last post by:
In the new Python game I'm developing, I need to crop out individual tiles from larger tilesets, and maintain transparency. Unfortunately, I've run into major deficiencies in both Tkinter and PIL...
9
by: Edilmar | last post by:
Hi, First of all, I'm new in Python... I have worked with manu langs and IDEs, like Delphi, VB, JBuilder, Eclipse, Borland C++, Perl, etc... Then, today I think IDEs like Delphi have a...
9
by: Rick Muller | last post by:
I have a problem that I would like to get some advice on from other Pythonistas. I currently manage a (soon to be) open source project for displaying molecular graphics for a variety of different...
5
by: eesun | last post by:
Hi, I've downloaded the dislin package for the scientific plotting. And I have already created the application window with Tkinter (menu, canvas, status bar..). I want to integrate the Dislin...
7
by: Justin Ezequiel | last post by:
What font is Tkinter using for displaying utf-8 characters? On my Windows XP, most of the characters with names (unicodedata.name) are displayed WYSIWYG. However, on my Mandrake (warning: Linux...
3
by: Matt Hammond | last post by:
Here's a strange one in Tkinter that has me stumped: (I'm running python 2.4 on Suse Linux 9.3 64bit) I'm trying to make a set of Entry widgets with Label widgets to the left of each one, using...
3
by: Jo Schambach | last post by:
I am trying to write a GUI with tkinter that displays the stdout from a regular C/C++ program in a text widget. The idea i was trying to use was as follows: 1) use "popen" to execute the C/C++...
1
by: yvesd | last post by:
hello i want to intercept tkinter python system events like wm_delete_window and if possible for any window, but the newest code I've produced give me an error : Traceback (most recent call...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.