Python-Gtk3:动态类的单独图形化

时间:2016-05-06 10:16:16

标签: python gtk pygtk gtk3

如何在python中分隔Graphical classDynamic class? 好的,这是我的try代码块,它从输入中获取两个值,然后将它们传递给名为dynamic的类,最后要将它们连接起来,然后将标签区域上的那个连接打印出来。

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk

class classInputs(Gtk.Window):
    def __init__(self):

        Gtk.Window.__init__(self, title="Inputs try window")
        self.set_border_width(10)
        self.set_size_request(200,100)

                # Layout
        vertical_box = Gtk.Box(orientation = Gtk.Orientation.VERTICAL, spacing = 8)
        self.add(vertical_box)


                #userName input
        self.input1 = Gtk.Entry()
        self.input1.set_text("")
        self.input1.set_size_request(120,200)
        vertical_box.pack_start(self.input1, True, True, 0)


               #Password input
        self.input2 = Gtk.Entry()
        self.input2.set_text("")
#        self.password.set_visibility(False)
        vertical_box.pack_start(self.input2, True, True, 0)


                #create login botton here
        self.button = Gtk.Button(label="click me to login")
        self.button.connect("clicked", self.function)
        vertical_box.pack_start(self.button, True, True, 0)

                #create label
        self.label= Gtk.Label()
        vertical_box.pack_start(self.label, True, True, 0)

    #function of the button here bech ki tenzel 3al button y7ot lencode fel input 1
    def function (self, widget):
        self.in1 = self.input1.get_text()
        self.in2 = self.input2.get_text()
        passing_values = dynamic(self.in1,self.in2)
        passing_values.concatinate()
        self.label.set_text(passing_values.out)


class dynamic(object):
    def __init__(self,text1,text2):
        self.value1 = text1
        self.value2 = text2
    def concatinate(self):
        self.out = self.value1+self.value2

shinerghost = classInputs()
shinerghost.connect("delete-event",Gtk.main_quit)
shinerghost.show_all()
Gtk.main()

And here my output work well 所以我想制作相同的东西,但我需要将动态类放入其他文件,而不是包含图形代码的同一文件。 应该怎么做这个分离代码?

0 个答案:

没有答案