采用Python编写Tecplot ADDON [01] GUI的问题 - 悲催的科学匠人 - 冷水's blog

采用Python编写Tecplot ADDON [01] GUI的问题

冷水 posted @ 2013年10月09日 19:06 in python with tags python tecplot , 2222 阅读

采用python写teccplot addon时,GUI是一个问题。tecplot自己带的python是2.5版(据说最新的tec360 13已经是基于python 2.7了),因此内含的GUI库只有Tkinter。Tkinter控件太少了,连下拉式选单都没有。Pmw实现了更多控件,于是打算手动安装Pmw到tecplot的python中。

 

方法很简单,找到一个Pmw(我直接用了系统的python2.7自带的Pmw),直接拷贝到tec360安装目录下的 

sudo cp -r /usr/lib/python2.7/dist-packages/Pmw/ /opt/tec360/lib/python2.5.1/lib/python2.5

然后需要设置一下chown和chmod

 

试试这个pmw程序

from Tkinter import *
import Pmw
root = Tk()
root.option_readfile('optionDB')
root.title('ComboBox 2')
Pmw.initialise()

choice = None

def choseEntry(entry):
    print 'You chose "%s"' % entry
    choice.configure(text=entry)

asply = ("The Mating of the Wersh", "Two Netlemeng of Verona", "Twelfth Thing", "The Chamrent of Venice", "Thamle", "Ring Kichard the Thrid")

choice = Label(root, text='Choose play', relief=SUNKEN, padx=20, pady=20)
choice.pack(expand=1, fill=BOTH, padx=8, pady=8)

combobox = Pmw.ComboBox(root, label_text='Play:', labelpos='wn',
                        listbox_width=24, dropdown=1,
                        selectioncommand=choseEntry,
                        scrolledlist_items=asply)
combobox.pack(fill=BOTH, expand=1, padx=8, pady=8)

combobox.selectitem(asply[0])

root.mainloop()

执行的结果如图

 

经过初步测试,Python and Tkinter Programming 上第四章的Pmw测试代码大都可以直接在tec360中运行,只有notebooks和notebookr因为是过时的控件已经在目前的Pmw库中删除。此外, notebook的setnaturalpagesize函数变更为setnaturalsize。

 

 

这样,我们就可以直接采用更炫的Pmw控件库和Tkinter一起编写tecplot python addon的界面了。

 
 
 
但是还有一个问题,目前看来没有合适的基于Tkinter/Pmw的可视化GUI设计工具。网上找了几个,ptkbg、visual python tkinter IDE之类,似乎都很烂。
 
此外,tecplot自带的tkinter里面连ttk也没有。尝试手工拷贝ttk,但是不能用,可能没那么简单。ttk里面有类似treeview的控件,是tkinter和pmw没有的。
 
总之,这个阉割版的python 2.5写GUI还是有些费劲。
 
Avatar_small
AP SSC fa 1 Model Pa 说:
2022年9月09日 01:57

Formative Assessment means not only an examination, it includes various aspects such as Examination in completed lessons, Reflections, Project work done on the allotted topic and Self also Prepared notes etc. AP SSC fa 1 Model Paper Candidates of Telugu Medium, English Medium & Urdu Medium of the AP State can download the AP 10th Class FA 4 Model Paper 2023 Pdf with answers for the regular exams conducted by the Directorate of Government Examinations, Andhra Pradesh.

Avatar_small
Emma 说:
2023年1月22日 03:02

It can be difficult to write a Tecplot ADDON GUI using Python. The version of Python that comes with Tecplot is 2.5, meaning the only CBD Hemp Oil GUI library included is Tkinter. Unfortunately, Tkinter controls are quite limited and do not include a drop-down menu. To access more complex controls, it is necessary to manually install the Pmw library into Tecplot's Python.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter
Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee