コード例 #1
0
ファイル: entry.py プロジェクト: Geotexan/experiments
    def __init__(self, val = 0, min_val = 0, max_val = 99, **kwargs):
        Table.__init__(self, cols = 2, rows = 2, horizontal_spacing = 2, vertical_spacing = 2, **kwargs)

        self.input = Entry("", draw_border=False)
        self.input.test_value = self._input_test_value
        self.input.connect("on-change", self.on_input_change)
        self.input.fill = True

        self.input.width = 30

        self.up = SpinButtonButton(up=True)
        self.down = SpinButtonButton(up=False)

        #: current value
        self.val = val

        #: minimum allowed value
        self.min_val = min_val

        #: maximum valid value
        self.max_val = max_val

        self.attach(self.input, 0, 1, 0, 2)
        self.attach(self.up, 1, 2, 0, 1)
        self.attach(self.down, 1, 2, 1, 2)

        self.connect_child(self.up, "on-mouse-down", self.on_up_pressed)
        self.connect_child(self.down, "on-mouse-down", self.on_down_pressed)
        self._direction = 0
コード例 #2
0
 def __init__(self, canvas):
     self.canvas = canvas
     self.table = Table(self.canvas,
                        Point(100, 25),
                        col_width=150,
                        font_size=10)
     self.selected_car = None
     self.show_route = False
     self.follow_car = False
     self.show_route_btn = Button(
         self.flip_show_route,
         self.canvas,
         Point(self.canvas.width / 2, 320),
         width=200,
         height=30,
         label='Show Route',
         font_size=10,
     )
     self.follow_btn = Button(
         self.flip_follow_car,
         self.canvas,
         Point(self.canvas.width / 2, 360),
         width=200,
         height=30,
         label='Follow Selected Car',
         font_size=10,
     )
     self.buttons = [self.show_route_btn, self.follow_btn]
コード例 #3
0
 def __init__(self, canvas):
     self.canvas = canvas
     self.table = Table(self.canvas,
                        Point(50, 10),
                        col_width=150,
                        font_size=10)
     self.selected_item = None
コード例 #4
0
    def __init__(self, val=0, min_val=0, max_val=99, **kwargs):
        Table.__init__(self,
                       cols=2,
                       rows=2,
                       horizontal_spacing=2,
                       vertical_spacing=2,
                       **kwargs)

        self.input = Entry("", draw_border=False)
        self.input.test_value = self._input_test_value
        self.input.connect("on-change", self.on_input_change)
        self.input.fill = True

        self.input.width = 30

        self.up = SpinButtonButton(up=True)
        self.down = SpinButtonButton(up=False)

        #: current value
        self.val = val

        #: minimum allowed value
        self.min_val = min_val

        #: maximum valid value
        self.max_val = max_val

        self.attach(self.input, 0, 1, 0, 2)
        self.attach(self.up, 1, 2, 0, 1)
        self.attach(self.down, 1, 2, 1, 2)

        self.connect_child(self.up, "on-mouse-down", self.on_up_pressed)
        self.connect_child(self.down, "on-mouse-down", self.on_down_pressed)
        self._direction = 0
コード例 #5
0
    def __init__(self,
                 contents=None,
                 border=1,
                 step_size=None,
                 scroll_horizontal="auto",
                 scroll_vertical="auto",
                 **kwargs):
        Table.__init__(self,
                       rows=2,
                       cols=2,
                       padding=[border, 0, 0, border],
                       **kwargs)

        self.viewport = Viewport(x_align=0, y_align=0)
        self.interactive, self.can_focus = True, True

        if step_size:
            self.step_size = step_siz

        #: with of the surrounding border in pixels
        self.border = border

        #: visibility of the horizontal scroll bar. True for always, False for never and "auto" for auto
        self.scroll_horizontal = scroll_horizontal

        #: visibility of the vertical scroll bar. True for always, False for never and "auto" for auto
        self.scroll_vertical = scroll_vertical

        #even if we are don't need the scrollbar, do we reserve space for it?
        self.reserve_space_vertical = False
        self.reserve_space_horizontal = False

        #: vertical scroll bar widget
        self.vscroll = ScrollBar()

        #: horizontal scroll bar widget
        self.hscroll = ScrollBar(horizontal=True)

        self.attach(self.viewport, 0, 1, 0, 1)
        self.attach(self.vscroll, 1, 2, 0, 1)
        self.attach(self.hscroll, 0, 1, 1, 2)

        if contents:
            if isinstance(contents, graphics.Sprite):
                contents = [contents]

            for sprite in contents:
                self.add_child(sprite)

        self.connect("on-mouse-scroll", self.__on_mouse_scroll)
        for bar in (self.vscroll, self.hscroll):
            self.connect_child(bar, "on-scroll", self.on_scroll)
            self.connect_child(bar, "on-scroll-step", self.on_scroll_step)
            self.connect_child(bar, "on-scroll-page", self.on_scroll_page)
コード例 #6
0
class InfoWindow:
    def __init__(self, canvas):
        self.canvas = canvas
        self.table = Table(self.canvas,
                           Point(100, 25),
                           col_width=150,
                           font_size=10)
        self.selected_car = None
        self.show_route = False
        self.follow_car = False
        self.show_route_btn = Button(
            self.flip_show_route,
            self.canvas,
            Point(self.canvas.width / 2, 320),
            width=200,
            height=30,
            label='Show Route',
            font_size=10,
        )
        self.follow_btn = Button(
            self.flip_follow_car,
            self.canvas,
            Point(self.canvas.width / 2, 360),
            width=200,
            height=30,
            label='Follow Selected Car',
            font_size=10,
        )
        self.buttons = [self.show_route_btn, self.follow_btn]

    def set_selected_car(self, car):
        self.selected_car = car

    def flip_show_route(self):
        self.show_route = not self.show_route

    def flip_follow_car(self):
        self.follow_car = not self.follow_car

    def initialize_table(self):
        for label, value in self.selected_car.get_info().items():
            self.table.add_row(label, value)

    def update_table(self):
        info = self.selected_car.get_info()
        rows = []
        for key, value in info.items():
            rows.append(TableRow(self.canvas, (key, value)))
        self.table.update_rows(rows)
コード例 #7
0
ファイル: scroll.py プロジェクト: Geotexan/experiments
    def __init__(self, contents=None, border=1, step_size=None,
                 scroll_horizontal="auto", scroll_vertical="auto",
                 **kwargs):
        Table.__init__(self, rows=2, cols=2, padding=[border, 0, 0, border], **kwargs)

        self.viewport = Viewport(x_align=0, y_align=0)
        self.interactive, self.can_focus = True, True

        if step_size:
            self.step_size = step_siz

        #: with of the surrounding border in pixels
        self.border = border

        #: visibility of the horizontal scroll bar. True for always, False for never and "auto" for auto
        self.scroll_horizontal = scroll_horizontal

        #: visibility of the vertical scroll bar. True for always, False for never and "auto" for auto
        self.scroll_vertical = scroll_vertical

        #even if we are don't need the scrollbar, do we reserve space for it?
        self.reserve_space_vertical = False
        self.reserve_space_horizontal = False


        #: vertical scroll bar widget
        self.vscroll = ScrollBar()

        #: horizontal scroll bar widget
        self.hscroll = ScrollBar(horizontal = True)

        self.attach(self.viewport, 0, 1, 0, 1)
        self.attach(self.vscroll, 1, 2, 0, 1)
        self.attach(self.hscroll, 0, 1, 1, 2)


        if contents:
            if isinstance(contents, graphics.Sprite):
                contents = [contents]

            for sprite in contents:
                self.add_child(sprite)

        self.connect("on-mouse-scroll", self.__on_mouse_scroll)
        for bar in (self.vscroll, self.hscroll):
            self.connect_child(bar, "on-scroll", self.on_scroll)
            self.connect_child(bar, "on-scroll-step", self.on_scroll_step)
            self.connect_child(bar, "on-scroll-page", self.on_scroll_page)
コード例 #8
0
class RoadInfoWindow:
    def __init__(self, canvas):
        self.canvas = canvas
        self.table = Table(self.canvas,
                           Point(50, 10),
                           col_width=150,
                           font_size=10)
        self.selected_item = None

    def set_selected_item(self, map_object):
        self.selected_item = map_object

    def update_table(self):
        if self.selected_item is None:
            self.table.delete_all_rows()
            return

        info = self.selected_item.get_info()

        if info and not self.table.rows:
            for label, value in info.items():
                self.table.add_row(label, value)
            return

        rows = []
        for key, value in info.items():
            rows.append(TableRow(self.canvas, (key, value)))
        self.table.update_rows(rows)
コード例 #9
0
    def resize_children(self):
        # give viewport all our space
        w, h = self.viewport.alloc_w, self.viewport.alloc_w
        self.viewport.alloc_w = self.width - self.horizontal_padding
        self.viewport.alloc_h = self.height - self.vertical_padding

        # then check if it fits
        area_w, area_h = self.viewport.get_container_size()
        hvis = self.scroll_horizontal is True or (
            self.scroll_horizontal == "auto" and self.width < area_w)
        if hvis:
            if self.reserve_space_horizontal:
                self.hscroll.opacity = 1
            else:
                self.hscroll.visible = True
        else:
            if self.reserve_space_horizontal:
                self.hscroll.opacity = 0
            else:
                self.hscroll.visible = False
        vvis = self.scroll_vertical is True or (self.scroll_vertical == "auto"
                                                and self.height < area_h)
        if vvis:
            if self.reserve_space_vertical:
                self.vscroll.opacity = 1
            else:
                self.vscroll.visible = True
        else:
            if self.reserve_space_vertical:
                self.vscroll.opacity = 0
            else:
                self.vscroll.visible = False

        Table.resize_children(self)

        if self.viewport.child:
            self.scroll_x(self.viewport.child.x)
            self.scroll_y(self.viewport.child.y)
コード例 #10
0
ファイル: scroll.py プロジェクト: Geotexan/experiments
    def resize_children(self):
        # give viewport all our space
        w, h = self.viewport.alloc_w, self.viewport.alloc_w
        self.viewport.alloc_w = self.width - self.horizontal_padding
        self.viewport.alloc_h = self.height - self.vertical_padding

        # then check if it fits
        area_w, area_h = self.viewport.get_container_size()
        hvis = self.scroll_horizontal is True or (self.scroll_horizontal == "auto" and self.width < area_w)
        if hvis:
            if self.reserve_space_horizontal:
                self.hscroll.opacity = 1
            else:
                self.hscroll.visible = True
        else:
            if self.reserve_space_horizontal:
                self.hscroll.opacity = 0
            else:
                self.hscroll.visible = False
        vvis = self.scroll_vertical is True or (self.scroll_vertical == "auto" and self.height < area_h)
        if vvis:
            if self.reserve_space_vertical:
                self.vscroll.opacity = 1
            else:
                self.vscroll.visible = True
        else:
            if self.reserve_space_vertical:
                self.vscroll.opacity = 0
            else:
                self.vscroll.visible = False

        Table.resize_children(self)


        if self.viewport.child:
            self.scroll_x(self.viewport.child.x)
            self.scroll_y(self.viewport.child.y)
コード例 #11
0
ファイル: scroll.py プロジェクト: Geotexan/experiments
 def add_child(self, *sprites):
     for sprite in sprites:
         if sprite in (self.viewport, self.vscroll, self.hscroll):
             Table.add_child(self, sprite)
         else:
             self.viewport.add_child(*sprites)
コード例 #12
0
ファイル: scroll.py プロジェクト: Geotexan/experiments
 def __setattr__(self, name, val):
     Table.__setattr__(self, name, val)
     if name in ("scroll_horizontal", "scroll_vertical"):
         self.queue_resize()
コード例 #13
0
 def add_child(self, *sprites):
     for sprite in sprites:
         if sprite in (self.viewport, self.vscroll, self.hscroll):
             Table.add_child(self, sprite)
         else:
             self.viewport.add_child(*sprites)
コード例 #14
0
ファイル: entry.py プロジェクト: Geotexan/experiments
 def __setattr__(self, name, val):
     Table.__setattr__(self, name, val)
     if name == "val" and val is not None:
         self.input.text = str(val)
コード例 #15
0
ファイル: main.py プロジェクト: averrin/demesne_old
    def _afterAppInit(self):
        """
            Fired after WinterApp initialisation
        """

        self.setWindowTitle(u'Нагрузочное тестирование БД')

        table=Table(self)
        # table.setEditTriggers(QAbstractItemView.NoEditTriggers)
        self.table=table

        forms=QWidget()
        forms.setLayout(QGridLayout())
        userform=QWidget()
        userform.setLayout(QFormLayout())
        userform.setLayout(QVBoxLayout())
        userform.layout().addWidget(QLabel(u'Список пользователей настраивается в файле main.cfg. <br>Пользователи циклично распределяются по потокам.'))

        dbform=QWidget()
        dbform.setLayout(QFormLayout())
        self.user=QLineEdit()
        self.user.setText(self.config.options.app.db_user)
        self.password=QLineEdit()
        self.password.setText(self.config.options.app.db_password)
        self.host=QLineEdit()
        self.host.setText(self.config.options.app.db_host)
        self.base=QLineEdit()
        self.base.setText(self.config.options.app.db_base)
        self.domain=QLineEdit()
        self.domain.setText(self.config.options.app.domain)
        dbform.layout().addRow(u'Пользователь',self.user)
        dbform.layout().addRow(u'Пароль',self.password)
        dbform.layout().addRow(u'Сервер',self.host)
        dbform.layout().addRow(u'Имя базы',self.base)
        dbform.layout().addRow(u'Имя домена',self.domain)


        threadform=QWidget()
        threadform.setLayout(QGridLayout())
        self.num=QSpinBox()
        self.num.setMaximum(999)
        self.num.setMinimum(1)
        self.num.setValue(self.config.options.app.threads_num)
        self.num.setToolTip(u'Значительно влияет на время выполнения и загрузку компьютера')

        threadform.layout().addWidget(QLabel(u'Количество потоков'),1,0)
        threadform.layout().addWidget(self.num,1,1)
        self.sepconnects=Switch(u'Создавать отдельные подключения на каждый запрос')
        threadform.layout().addWidget(self.sepconnects,3,0)
        self.skiperrors=Switch(u'Пропускать ошибки')
        threadform.layout().addWidget(self.skiperrors,4,0)

        self.fullc=Switch(u'Полный цикл')
        self.fullc.setChecked(True)
        self.fullc.stateChanged.connect(self.togglefull)
        threadform.layout().addWidget(self.fullc,5,0)
        self.minthreads=QSpinBox()
        self.minthreads.setValue(1)
        self.minthreads.setMaximum(999)
        self.minthreads.setMinimum(1)

        threadform.layout().addWidget(QLabel(u'Начально потоков'),6,0)
        threadform.layout().addWidget(self.minthreads,6,1)

        self.step=QSpinBox()
        self.step.setValue(1)
        self.step.setMaximum(999)
        self.step.setMinimum(1)
        threadform.layout().addWidget(QLabel(u'Шаг'),7,0)
        threadform.layout().addWidget(self.step,7,1)

        self.mc=QSpinBox()
        self.mc.setValue(0)
        self.mc.setMaximum(99999)
        self.mc.setMinimum(0)
        threadform.layout().addWidget(QLabel(u'Максимум запросов (0 = весь файл)'),2,0)
        threadform.layout().addWidget(self.mc,2,1)

        # options=QTabWidget()
        # options.addTab(dbform,u'Настройки БД')

        graphoptions=QWidget()
        graphoptions.setLayout(QFormLayout())
        # options.addTab(graphoptions,u'Настройки графика')
        self.notshowmavg=Switch(u'Не показывать среднюю по максимуму')
        graphoptions.layout().addRow('',self.notshowmavg)

        self.showlevel01=Switch(u'Всегда показывать линию уровня 0.1sec')
        graphoptions.layout().addRow('',self.showlevel01)
        self.showlevel1=Switch(u'Всегда показывать линию уровня 1sec')
        graphoptions.layout().addRow('',self.showlevel1)

        self.notshowerr=Switch(u'Не показывать ошибки')
        graphoptions.layout().addRow('',self.notshowerr)

        self.detail=Switch(u'Детальный отчет')
        threadform.layout().addWidget(self.detail,8,0)

        # graphoptions.layout().addRow('',self.detail)

        # forms.layout().addWidget(options,1,1)
        # forms.layout().addWidget(threadform,1,0)

        self.sideBar = WinterSideBar(self)
        threadform.layout().setAlignment(Qt.AlignTop)
        self.createSBAction('configure','MainOptions',threadform,toolbar=True)
        self.createSBAction('db','db settings',dbform,toolbar=True)
        self.createSBAction('graph','graph settings',graphoptions,toolbar=True)


        self.resize(1200,600)
        widget=QWidget()
        widget.setLayout(QVBoxLayout())
        widget.layout().addWidget(forms)
        widget.layout().addWidget(QLabel(u''))
        widget.layout().addWidget(table)


        buttons=QWidget()
        buttons.setLayout(QHBoxLayout())

        hb=QPushButton(u'Справка')
        hb.clicked.connect(self.help)

        self.progress=QProgressBar()
        buttons.layout().addWidget(hb)
        buttons.layout().addWidget(self.progress)

        spacerItem=QWidget()
        spacerItem.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum))
        buttons.layout().addWidget(spacerItem)
        sb=QPushButton(u'Поехали!')
        sb.clicked.connect(self.launch)
        buttons.layout().addWidget(sb)
        bb=QPushButton(u'Стоп')
        bb.clicked.connect(self.stop)
        buttons.layout().addWidget(bb)
        qb=QPushButton(u'Выход')
        qb.clicked.connect(self.quit)
        buttons.layout().addWidget(qb)

        self.help=QMainWindow()
        self.help.resize(800,600)
        self.help.setWindowTitle(u'Справка')
        hwidget=QWidget()
        hwidget.setLayout(QVBoxLayout())
        self.help.browser=QWebView()
        hwidget.layout().addWidget(self.help.browser)
        self.help.setCentralWidget(hwidget)


        self.viewer=QWebView()
        self.viewer.setFixedWidth(950)
        self.viewer.hide()

        wrapper=QWidget()
        wrapper.setLayout(QHBoxLayout())
        wrapper.layout().addWidget(widget)
        wrapper.layout().addWidget(self.viewer)

        widget.layout().addWidget(buttons)

        self.total=0
        self.callsnum=0
        self.errnum=0

        self.data=[]
        self.edata=[]
        self.mdata=[]
        self.tt=0
        self.tts=[]
        self.force_stop=False
        self.callsavg={}
        self.pdata={}
        self.cc={}

        self.args={}

        self.setMainWidget(wrapper)
        # self.sideBar = WinterSideBar(self)

        self.core.start()
コード例 #16
0
 def __setattr__(self, name, val):
     Table.__setattr__(self, name, val)
     if name == "val" and val is not None:
         self.input.text = str(val)
コード例 #17
0
 def __setattr__(self, name, val):
     Table.__setattr__(self, name, val)
     if name in ("scroll_horizontal", "scroll_vertical"):
         self.queue_resize()