示例#1
0
文件: main.py 项目: nbassler/tree
def main(args):
    app = QtWidgets.QApplication(sys.argv)

    v = MyView()
    v.show()
    m = MyModel()
    TreeCtrl(m, v)

    app.exec_()
示例#2
0
class MyController():
    def __init__(self, parent):
        self.parent = parent
        self.model = MyModel(self)  # initializes the model
        self.view = MyView(self)  #initializes the view
        #initialize objects in view
        #a non cheat way to do MVC wiht tkinter control variables
        #self.view.setEntry_text('Data')
        #self.view.setLabel_text('>')

    #event handlers
    def salirButtonPressed(self):
        self.parent.destroy()

    def calcularButtonPressed(self):
        key = self.view.getEntry_text_key()
        msg = self.view.getEntry_text_msg()
        self.model.clearList()
        if len(key):
            self.model.addToList(key[0])
        if len(msg):
            self.model.addToList(msg)
        if (len(key) and len(msg)):
            self.view.setLabel_text(self.getCipherText(self.model.getList()))

    def listChangedDelegate(self):
        #model internally chages and needs to signal a change
        print(self.model.getList())

    def getCipherText(self, in_list):
        key = in_list[0]
        msg = in_list[1]
        values = []
        print("Key = ", key, ord(key))
        start = time.time()
        vs = []
        for x in msg:
            vs.append(ord(x))
        print(vs)
        vv = []
        low_level_driver.send_key_byte(ord(key))
        for x in msg:
            time.sleep(0.01)
            low_level_driver.send_data_byte(ord(x))
            time.sleep(0.01)
            v = low_level_driver.get_byte()
            val = unichr(v)
            values.append(val)
            vv.append(v)
        print("Transaction finished. Time = ", time.time() - start)
        print(values)
        print(vv)
        return ''.join(values)
示例#3
0
class MyController():
    def __init__(self, env_height, env_width, populate_proba,
                 frame_per_second):
        self.model = MyModel(env_height, env_width, populate_proba)
        self.view = MyView(self.model, frame_per_second)

    def update_view(self):
        os.system('clear')
        self.view.update()

    def run_next_step(self):
        for line in self.model.env_matrix:
            for tile in line:
                if not tile.is_empty():
                    tile.agent.next_step()

    def start(self):

        frame_time_start = time.perf_counter()

        os.system('clear')
        self.update_view()

        while (True):
            sim_time_start = time.perf_counter()
            self.run_next_step()
            sim_running_time = time.perf_counter() - sim_time_start

            self.update_view()
            frame_time = time.perf_counter() - frame_time_start
            frame_time_start = time.perf_counter()

            print("sim_time={0} sec".format(sim_running_time))
            print("FPS={0}".format(self.view.frame_per_second))
            print("frame_duration_in_sec={0}".format(
                self.view.frame_duration_in_sec))
            print("frame_time={0} sec".format(frame_time))

            time_left_to_next_frame = self.view.frame_duration_in_sec - (
                time.perf_counter() - sim_time_start)
            if (time_left_to_next_frame > 0):
                time.sleep(time_left_to_next_frame)
示例#4
0
class MyController():

    def __init__(self, env_height, env_width,
                 populate_proba, frame_per_second):
        self.model = MyModel(env_height, env_width, populate_proba)
        self.view = MyView(self.model, frame_per_second)

    def update_view(self):
        os.system('clear')
        self.view.update()

    def run_next_step(self):
        for line in self.model.env_matrix:
            for tile in line:
                if not tile.is_empty():
                    tile.agent.next_step()

    def start(self):

        frame_time_start = time.perf_counter()

        os.system('clear')
        self.update_view()

        while (True):
            sim_time_start = time.perf_counter()
            self.run_next_step()
            sim_running_time = time.perf_counter() - sim_time_start

            self.update_view()
            frame_time = time.perf_counter() - frame_time_start
            frame_time_start = time.perf_counter()

            print("sim_time={0} sec".format(sim_running_time))
            print("FPS={0}".format(self.view.frame_per_second))
            print("frame_duration_in_sec={0}".format(self.view.frame_duration_in_sec))
            print("frame_time={0} sec".format(frame_time))

            time_left_to_next_frame = self.view.frame_duration_in_sec - (time.perf_counter() - sim_time_start)
            if (time_left_to_next_frame > 0):
                time.sleep(time_left_to_next_frame)
示例#5
0
 def __init__(self, env_height, env_width,
              populate_proba, frame_per_second):
     self.model = MyModel(env_height, env_width, populate_proba)
     self.view = MyView(self.model, frame_per_second)
示例#6
0
文件: main.py 项目: roboogle/gtkmvc3
#  version 2 of the License, or (at your option) any later version.
#
#  gtkmvc3 is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public
#  License along with this library; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor,
#  Boston, MA 02110, USA.
#
#  For more information on gtkmvc3 see <https://github.com/roboogle/gtkmvc3>
#  or email to the author Roberto Cavada <*****@*****.**>.
#  Please report bugs to <https://github.com/roboogle/gtkmvc3/issues>
#  or to <*****@*****.**>.

if __name__ == "__main__":

    from model import MyModel
    from controller import MyCtrl
    from view import MyView

    m = MyModel()
    v = MyView()
    c = MyCtrl(m, v)

    import gtk
    gtk.main()
    pass
示例#7
0
文件: main.py 项目: uncia/tools-1
#!/usr/bin/python

import gtk

from model import MyModel
from view import MyView
from ctrl import MyController

m = MyModel()
c = MyController(m)
v = MyView(c)

gtk.main()
示例#8
0
 def __init__(self, env_height, env_width, populate_proba,
              frame_per_second):
     self.model = MyModel(env_height, env_width, populate_proba)
     self.view = MyView(self.model, frame_per_second)
示例#9
0
 def __init__(self, parent):
     self.parent = parent
     self.model = MyModel(self)  # initializes the model
     self.view = MyView(self)  #initializes the view