学习Python - 第一个项目 [英] Learning Python - First Project

查看:68
本文介绍了学习Python - 第一个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我是Python的新手,我正在尝试用Python写一个小前端到另一个应用程序。


我想要的是有一个gui弹出式列出一些带有几个

按钮的项目。该计划的内容我没有遇到任何麻烦,但是

我是GUI部分(或者更准确地说,是GUI之间的过渡
件)。


弹出的第一个GUI列出了列表框中的一些组,并给出了用户可以选择创建新组,打开组,重命名



组,或删除该组。新组和重命名组按钮

会弹出一个对话框,询问名称/新名称。 Open Group是

打开另一个GUI列出该组中的项目列表与

类似的选项(新项目,开放项目,重命名项目,删除

项目。


我的问题是,我该如何创建所有这些GUI?每个GUI

应该是自己的类,有自己的__init__吗?然后是第一个GUI

root(我现在如何设置)和所有其他使用Toplevel()的GUI?


我希望这是有意义的(因为它只在我的

头部才有意义。)


谢谢任何建议。

解决方案

4月23日上午9:52,KDawg44< KDaw ... @ gmail.comwrote:





我是Python的新手,我正在尝试用Python写一个小前端来获得另一个应用程序。


我想要的是有一个gui弹出式列出一些带有几个

按钮的项目。该计划的内容我没有遇到任何麻烦,但是

我是GUI部分(或者更准确地说,是GUI之间的过渡
件)。


弹出的第一个GUI列出了列表框中的一些组,并给出了用户可以选择创建新组,打开组,重命名



组,或删除该组。新组和重命名组按钮

会弹出一个对话框,询问名称/新名称。 Open Group是

打开另一个GUI列出该组中的项目列表与

类似的选项(新项目,开放项目,重命名项目,删除

项目。


我的问题是,我该如何创建所有这些GUI?每个GUI

应该是自己的类,有自己的__init__吗?然后是第一个GUI

root(我现在如何设置)和所有其他使用Toplevel()的GUI?


我希望这是有意义的(因为它只在我的

头部才有意义。)


谢谢任何建议。






你应该可以创建一个主窗口作为root并使用

标准对话框为您提到的对话框。至于Open

Group按钮,您可以使用树小部件而不是打开另一个

窗口。您可以将树放在分离器窗口或其他东西中,并且它可能看起来更好。当然,你可以做另一个窗口,但它b ​​/ b
将是一个自定义的手动编码窗口而不是标准对话框。那个

意味着它确实会是另一个拥有自己的等级
" __ init __"。


你可以设置两个标准对话框和您的自定义对话框

" ShowModal"然后你不需要使用Toplevel()。


我假设您正在使用Tkinter作为前端GUI。你可能会在wxPython上看到
。它有一个很棒的演示,你可以下载
,它可能会给你一些额外的想法来实现

www.wxpython.org


Mike


4月23日上午9:52,KDawg44< KDaw ... @ gmail.comwrote:





我是Python的新手,我正在尝试用Python写一个小前端来获得另一个应用程序。


我想要的是拥有一个gui弹出列出一些带有几个

按钮的项目。该计划的内容我没有遇到任何麻烦,但是

我是GUI部分(或者更准确地说,是GUI之间的过渡
件)。


弹出的第一个GUI列出了列表框中的一些组,并给出了用户可以选择创建新组,打开组,重命名



组,或删除该组。新组和重命名组按钮

会弹出一个对话框,询问名称/新名称。 Open Group是

打开另一个GUI列出该组中的项目列表与

类似的选项(新项目,开放项目,重命名项目,删除

项目。


我的问题是,我该如何创建所有这些GUI?每个GUI

应该是自己的类,有自己的__init__吗?然后是第一个GUI

root(我现在如何设置)和所有其他使用Toplevel()的GUI?


我希望这是有意义的(因为它只在我的

头部才有意义。)


谢谢任何建议。



我假设您正在使用Tkinter作为GUI前端。你应该只需要为你的新组使用标准对话框。和

"重命名组"对话框和另一个自定义的手工编码对话框

one。所有这三个都可以使用ShowModal()而不是Toplevel()来调用。

是的,如果你将自定义对话框分成

单独的类,它将会起作用。 br />

您还可以将用于将项目

列出的GUI的信息放入树中。某种小部件,可能带有分割器窗口。我虽然没有给Tkinter的树小部件带来太多运气。 PMW和Tix

都有相当差的文档,除非你喜欢手册页。您可以检查

而不是wxPython。它有一个非常好的演示,它非常擅长

,它不仅可以显示它能做什么,还可以完成它的工作方式: www.wxpython.org


祝你好运!


Mike


4月23日下午1点44分,kyoso ... @ gmail.com写道:


4月23日上午9:52,KDawg44< KDaw ... @ gmail.comwrote:



< blockquote class =post_quotes>
我是Python的新手,我正在尝试用Python写一个小前端到另一个应用程序。


我想要的是弹出一个带有几个

按钮的项目。程序的内容我没有遇到任何麻烦,但是我是GUI部分(或更确切地说,GUI之间的转换
件)。


弹出的第一个GUI列出了列表框中的一些组,并给出了用户可以选择创建一个新的
组,打开一个组,重命名

组,或删除该组。新组和重命名组按钮

会弹出一个对话框,询问名称/新名称。 Open Group是

打开另一个GUI列出该组中的项目列表与

类似的选项(新项目,开放项目,重命名项目,删除

项目)。


我的问题是,我该如何创建所有这些GUI?每个GUI

应该是自己的类,有自己的__init__吗?然后是第一个GUI

root(我现在如何设置)和所有其他使用Toplevel()的GUI?


我希望这是有道理的(因为它只在我的

头部才有意义)。


谢谢任何建议。



我假设您正在使用Tkinter作为GUI前端。你应该只需要为你的新组使用标准对话框。和

"重命名组"对话框和另一个自定义的手工编码对话框

one。所有这三个都可以使用ShowModal()而不是Toplevel()来调用。

是的,如果你将自定义对话框分成

单独的类,它将会起作用。 br />

您还可以将用于将项目

列出的GUI的信息放入树中。某种小部件,可能带有分割器窗口。我虽然没有给Tkinter的树小部件带来太多运气。 PMW和Tix

都有相当差的文档,除非你喜欢手册页。您可以检查

而不是wxPython。它有一个非常好的演示,它非常擅长

,它不仅可以显示它能做什么,还可以完成它的工作方式: www.wxpython.org


祝你好运!


Mike



对于双重发布抱歉。今天我没有正确发布这件事。


Mike


Hi,

I am new to Python and am trying to write a little front end to
another application in Python.

What I want is to have a gui pop up listing some items with several
buttons. The guts of the program I am not having any trouble with but
the GUI part I am (or more accurately, the transition between GUI
pieces).

The first GUI that pops up lists some groups in a listbox and gives
the user the choice to create a new group, open a group, rename the
group, or delete the group. The new group and rename group buttons
pop up a dialog gui asking for the name/new name. The Open Group is
to open another GUI listing projects within that group in a list with
similar options (New Project, Open Project, Rename Project, Delete
Project).

My question is, how should I create all these GUIs? Should each GUI
be its own class with its own __init__? Then is the first GUI the
root (how I have it set up now) and all other GUIs using Toplevel()?

I hope this makes sense (because it only sort of makes sense in my
head).

THanks for any suggestions.

解决方案

On Apr 23, 9:52 am, KDawg44 <KDaw...@gmail.comwrote:

Hi,

I am new to Python and am trying to write a little front end to
another application in Python.

What I want is to have a gui pop up listing some items with several
buttons. The guts of the program I am not having any trouble with but
the GUI part I am (or more accurately, the transition between GUI
pieces).

The first GUI that pops up lists some groups in a listbox and gives
the user the choice to create a new group, open a group, rename the
group, or delete the group. The new group and rename group buttons
pop up a dialog gui asking for the name/new name. The Open Group is
to open another GUI listing projects within that group in a list with
similar options (New Project, Open Project, Rename Project, Delete
Project).

My question is, how should I create all these GUIs? Should each GUI
be its own class with its own __init__? Then is the first GUI the
root (how I have it set up now) and all other GUIs using Toplevel()?

I hope this makes sense (because it only sort of makes sense in my
head).

THanks for any suggestions.

Hi,

You should be able to create one main window as "root" and use
standard dialogs for the dialogs you mentioned. As for the "Open
Group" button, you might use a tree widget instead of opening another
window. You could put the tree in a splitter window or something and
it might look nicer. Of course, you can do another window, but it
would be a custom, hand-coded window and NOT a standard dialog. That
would mean that it would indeed be another class with its own
"__init__".

You can set both the standard dialogs and your custom one to
"ShowModal" and then you shouldn''t need to use Toplevel().

I am assuming you are using Tkinter for your front-end GUI. You might
also take a gander at wxPython. It has an excellent demo you could
download and it might give you some additional ideas for
implementation: www.wxpython.org .

Mike


On Apr 23, 9:52 am, KDawg44 <KDaw...@gmail.comwrote:

Hi,

I am new to Python and am trying to write a little front end to
another application in Python.

What I want is to have a gui pop up listing some items with several
buttons. The guts of the program I am not having any trouble with but
the GUI part I am (or more accurately, the transition between GUI
pieces).

The first GUI that pops up lists some groups in a listbox and gives
the user the choice to create a new group, open a group, rename the
group, or delete the group. The new group and rename group buttons
pop up a dialog gui asking for the name/new name. The Open Group is
to open another GUI listing projects within that group in a list with
similar options (New Project, Open Project, Rename Project, Delete
Project).

My question is, how should I create all these GUIs? Should each GUI
be its own class with its own __init__? Then is the first GUI the
root (how I have it set up now) and all other GUIs using Toplevel()?

I hope this makes sense (because it only sort of makes sense in my
head).

THanks for any suggestions.

I am assuming you are using Tkinter for your GUI front-end. You should
be able to just use standard dialog boxes for your "new group" and
"rename group" dialogs and a custom hand-coded dialog for the other
one. All three can be called with ShowModal() instead of Toplevel().
And yes, the custom dialog would work best if you made it into a
separate class.

You could also put that information for the GUI that list projects
into a "tree" widget of some sort, maybe with a splitter window. I
haven''t had much luck with Tkinter''s tree widgets though. PMW and Tix
both have rather poor docs unless you enjoy man pages. You might check
out wxPython instead. It has an excellent demo that is very good at
showing you not only what all it can do, but how it is done: www.wxpython.org.

Good luck!

Mike


On Apr 23, 1:44 pm, kyoso...@gmail.com wrote:

On Apr 23, 9:52 am, KDawg44 <KDaw...@gmail.comwrote:

Hi,

I am new to Python and am trying to write a little front end to
another application in Python.

What I want is to have a gui pop up listing some items with several
buttons. The guts of the program I am not having any trouble with but
the GUI part I am (or more accurately, the transition between GUI
pieces).

The first GUI that pops up lists some groups in a listbox and gives
the user the choice to create a new group, open a group, rename the
group, or delete the group. The new group and rename group buttons
pop up a dialog gui asking for the name/new name. The Open Group is
to open another GUI listing projects within that group in a list with
similar options (New Project, Open Project, Rename Project, Delete
Project).

My question is, how should I create all these GUIs? Should each GUI
be its own class with its own __init__? Then is the first GUI the
root (how I have it set up now) and all other GUIs using Toplevel()?

I hope this makes sense (because it only sort of makes sense in my
head).

THanks for any suggestions.


I am assuming you are using Tkinter for your GUI front-end. You should
be able to just use standard dialog boxes for your "new group" and
"rename group" dialogs and a custom hand-coded dialog for the other
one. All three can be called with ShowModal() instead of Toplevel().
And yes, the custom dialog would work best if you made it into a
separate class.

You could also put that information for the GUI that list projects
into a "tree" widget of some sort, maybe with a splitter window. I
haven''t had much luck with Tkinter''s tree widgets though. PMW and Tix
both have rather poor docs unless you enjoy man pages. You might check
out wxPython instead. It has an excellent demo that is very good at
showing you not only what all it can do, but how it is done:www.wxpython.org.

Good luck!

Mike

Sorry about the dual posting. This thing isn''t posting correctly for
me today.

Mike


这篇关于学习Python - 第一个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆