472,780 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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


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?

#!/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)

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

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

def runCommand(self, selection):
print 'You selected in: ', 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)
def makeWidgets(self, text):
frame = LabelFrame(self, text=text)
list = Listbox(frame, relief=SUNKEN)
sbar = Scrollbar(frame)
button = Button(frame, text='Move here',
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)
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):
self.pack(expand=YES, fill=BOTH)
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")


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")


Oct 8 '06 #1
0 1350

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

Similar topics

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...
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...
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...
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...
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...
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...
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...
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++...
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...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?

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.