예제 #1
0
    def main(self):
        body = gui.VBox(width='100%', height='100%')
        main_container = gui.VBox(width=400,
                                  height=140,
                                  style={
                                      'align': 'center',
                                      'border': '5px #FFAC55 solid'
                                  })
        btn_container = gui.HBox(width=300, height=30)
        link_to_github = gui.Link(
            'https://github.com/npes87184/PyM3UGenerator', 'Fork me here')

        self.lbl = gui.Label('Please choose a folder')
        self.select_bt = gui.Button('Select folder', width=100, height=30)
        self.go_bt = gui.Button('Go', width=100, height=30)

        self.select_bt.onclick.do(self.on_select_btn_pressed)
        self.go_bt.onclick.do(self.on_go_btn_pressed)

        btn_container.append(self.select_bt)
        btn_container.append(self.go_bt)

        main_container.append(self.lbl)
        main_container.append(btn_container)
        main_container.append(link_to_github)
        body.append(main_container)

        return body
예제 #2
0
    def main(self):
        # the arguments are    width - height - layoutOrientationOrizontal
        self.main_container = gui.Container(margin='0px auto')
        self.main_container.set_size(1020, 600)
        self.main_container.set_layout_orientation(gui.Container.LAYOUT_VERTICAL)

        self.title = gui.Label('Mine Field GAME')
        self.title.set_size(1000, 30)
        self.title.style['margin'] = '10px'
        self.title.style['font-size'] = '25px'
        self.title.style['font-weight'] = 'bold'

        self.info = gui.Label('Collaborative minefiled game. Enjoy.')
        self.info.set_size(400, 30)
        self.info.style['margin'] = '10px'
        self.info.style['font-size'] = '20px'

        self.lblMineCount = gui.Label('Mines')
        self.lblMineCount.set_size(100, 30)
        self.lblFlagCount = gui.Label('Flags')
        self.lblFlagCount.set_size(100, 30)

        self.time_count = 0
        self.lblTime = gui.Label('Time')
        self.lblTime.set_size(100, 30)

        self.btReset = gui.Button('Restart')
        self.btReset.set_size(100, 30)
        self.btReset.onclick.do(self.new_game)

        self.horizontal_container = gui.Container()
        self.horizontal_container.style['display'] = 'block'
        self.horizontal_container.style['overflow'] = 'auto'
        self.horizontal_container.set_layout_orientation(gui.Container.LAYOUT_HORIZONTAL)
        self.horizontal_container.style['margin'] = '10px'
        self.horizontal_container.append(self.info)
        imgMine = gui.Image('/my_resources:mine.png')
        imgMine.set_size(30, 30)
        self.horizontal_container.append([imgMine, self.lblMineCount])
        imgFlag = gui.Image('/my_resources:flag.png')
        imgFlag.set_size(30, 30)
        self.horizontal_container.append([imgFlag, self.lblFlagCount, self.lblTime, self.btReset])

        self.minecount = 0  # mine number in the map
        self.flagcount = 0  # flag placed by the players

        self.link = gui.Link("https://github.com/dddomodossola/remi",
                             "This is an example of REMI gui library.")
        self.link.set_size(1000, 20)
        self.link.style['margin'] = '10px'

        self.main_container.append([self.title, self.horizontal_container, self.link])

        self.new_game(self)

        self.stop_flag = False
        self.display_time()
        # returning the root widget
        return self.main_container
예제 #3
0
 def menu_became_a_patron(self, widget):
     dialog = gui.GenericDialog(
         "Became a Patron", "This editor is made for you with passion. \nIt would be fantastic if you give a contribution, also a little one. ;-)", width="50%")
     dialog.add_field("link", gui.Link("https://www.patreon.com/remigui",
                                       "Click this link to Donate", True, style={'font-weight': 'bolder'}))
     dialog.children["message"].style['white-space'] = 'pre'
     dialog.cancel.style['display'] = 'none'
     dialog.conf.set_text("Back")
     dialog.show(self)
예제 #4
0
파일: web.py 프로젝트: misiekagh/aghp1.py
    def idle(self):
        global cList
        if uiuser.clientID != '': self.root.clientID = uiuser.clientID

        try:
            self.tstHang += 1
        except:
            self.tstHang = 1

        try:
            cid = self.root.clientID
        except:
            pass
        else:
            if cid == '' and not self.root.children and self.websockets:
                print(
                    '--- Idle -- Brak klienta - przekierowuj na logowanie. {}'.
                    format(self.websockets))
                self.root.append(
                    gui.Link(url='https://aixm.kpgeo.pl/login',
                             text='Zaloguj się',
                             open_new_window=False))
                self.execute_javascript(
                    'window.location.replace("https://aixm.kpgeo.pl/login");')

            elif cid != '' and cid not in cList.keys():
                cList[cid] = self.__dict__.copy(
                )  # dodaj klienta do słownika i przypisz aktualny appstate
                print('--- Idle -- Zalogowany klient {}. Tworze interfejs'.
                      format(cid))
                if cid == 'admin':
                    self.build_admin_ui(cid)
                elif cid == 'test':
                    self.build_test_ui(cid)
                else:
                    self.build_ui(cid)
                print('--- Idle -- Klient {}  ma zaalokowany interfejs: {}.'.
                      format(cid, cList[cid]))

            elif cid == '' and self.tstHang > 30 and not self.websockets:
                print('--- Idle -- Brak klienta - Websocket timeout!.')
                self.tstHang = 1
                headers = {
                    'Content-type': 'text/plain',
                    'Refresh': '0;url=https://aixm.kpgeo.pl/login'
                }
                return ['Requested user logging in.', headers]

            try:
                cList[cid]['root'].cRun += 1
            except:
                pass

            map(self._log.debug,
                self.dump_appstate('--- Idle -- ', self.__dict__))
예제 #5
0
    def main(self):
        # the arguments are	width - height - layoutOrientationOrizontal
        self.main_container = gui.Widget(1020, 600, False, 10)

        self.title = gui.Label(1000, 30, 'Mine Field GAME')
        self.title.style['font-size'] = '25px'
        self.title.style['font-weight'] = 'bold'

        self.info = gui.Label(400, 30, 'Collaborative minefiled game. Enjoy.')
        self.info.style['font-size'] = '20px'

        self.lblMineCount = gui.Label(100, 30, 'Mines')
        self.lblFlagCount = gui.Label(100, 30, 'Flags')

        self.time_count = 0
        self.lblTime = gui.Label(100, 30, 'Time')

        self.btReset = gui.Button(100, 30, 'Restart')
        self.btReset.set_on_click_listener(self, "new_game")

        self.horizontal_container = gui.Widget(1000, 30, True, 0)
        self.horizontal_container.append('info', self.info)
        self.horizontal_container.append('icon_mine',
                                         gui.Image(30, 30, '/res/mine.png'))
        self.horizontal_container.append('info_mine', self.lblMineCount)
        self.horizontal_container.append('icon_flag',
                                         gui.Image(30, 30, '/res/flag.png'))
        self.horizontal_container.append('info_flag', self.lblFlagCount)
        self.horizontal_container.append('info_time', self.lblTime)
        self.horizontal_container.append('reset', self.btReset)

        self.minecount = 0  #mine number in the map
        self.flagcount = 0  #flag placed by the players

        self.link = gui.Link(1000, 20, "https://github.com/dddomodossola/remi",
                             "This is an example of REMI gui library.")

        self.main_container.append('title', self.title)
        self.main_container.append('horizontal_container',
                                   self.horizontal_container)
        self.main_container.append('link', self.link)

        self.new_game()

        self.display_time()
        # returning the root widget
        return self.main_container
예제 #6
0
    def __init__(self,
                 title,
                 message,
                 link_url,
                 link_text,
                 width=500,
                 height=200):
        super(LinkDialog, self).__init__(width=width,
                                         height=height,
                                         frame_height=height - 300,
                                         title=title,
                                         message=message,
                                         confirm_name='Done')

        self.link = gui.Link(link_url,
                             link_text,
                             width=200,
                             height=30,
                             margin='10px')

        self.append_label(self.link, bold=False)
예제 #7
0
    def main(self):
        verticalContainer = gui.Widget(width=540)
        verticalContainer.style['display'] = 'block'
        verticalContainer.style['overflow'] = 'hidden'

        horizontalContainer = gui.Widget(width='100%', layout_orientation=gui.Widget.LAYOUT_HORIZONTAL, margin='0px')
        horizontalContainer.style['display'] = 'block'
        horizontalContainer.style['overflow'] = 'auto'
        
        subContainerLeft = gui.Widget(width=320)
        subContainerLeft.style['display'] = 'block'
        subContainerLeft.style['overflow'] = 'auto'
        subContainerLeft.style['text-align'] = 'center'
        self.img = gui.Image('/res/logo.png', width=100, height=100, margin='10px')
        self.img.set_on_click_listener(self, 'on_img_clicked')

        self.table = gui.Table(width=300, height=200, margin='10px')
        self.table.from_2d_matrix([['ID', 'First Name', 'Last Name'],
                                   ['101', 'Danny', 'Young'],
                                   ['102', 'Christine', 'Holand'],
                                   ['103', 'Lars', 'Gordon'],
                                   ['104', 'Roberto', 'Robitaille'],
                                   ['105', 'Maria', 'Papadopoulos']])

        # the arguments are	width - height - layoutOrientationOrizontal
        subContainerRight = gui.Widget()
        subContainerRight.style['width'] = '220px'
        subContainerRight.style['display'] = 'block'
        subContainerRight.style['overflow'] = 'auto'
        subContainerRight.style['text-align'] = 'center'
        self.count = 0
        self.counter = gui.Label('', width=200, height=30, margin='10px')

        self.lbl = gui.Label('This is a LABEL!', width=200, height=30, margin='10px')

        self.bt = gui.Button('Press me!', width=200, height=30, margin='10px')
        # setting the listener for the onclick event of the button
        self.bt.set_on_click_listener(self, 'on_button_pressed')

        self.txt = gui.TextInput(width=200, height=30, margin='10px')
        self.txt.set_text('This is a TEXTAREA')
        self.txt.set_on_change_listener(self, 'on_text_area_change')

        self.spin = gui.SpinBox(100, width=200, height=30, margin='10px')
        self.spin.set_on_change_listener(self, 'on_spin_change')

        self.check = gui.CheckBoxLabel('Label checkbox', True, width=200, height=30, margin='10px')
        self.check.set_on_change_listener(self, 'on_check_change')

        self.btInputDiag = gui.Button('Open InputDialog', width=200, height=30, margin='10px')
        self.btInputDiag.set_on_click_listener(self, 'open_input_dialog')

        self.btFileDiag = gui.Button('File Selection Dialog', width=200, height=30, margin='10px')
        self.btFileDiag.set_on_click_listener(self, 'open_fileselection_dialog')

        self.btUploadFile = gui.FileUploader('./', width=200, height=30, margin='10px')
        self.btUploadFile.set_on_success_listener(self, 'fileupload_on_success')
        self.btUploadFile.set_on_failed_listener(self, 'fileupload_on_failed')

        items = ('Danny Young','Christine Holand','Lars Gordon','Roberto Robitaille')
        self.listView = gui.ListView.new_from_list(items, width=300, height=120, margin='10px')
        self.listView.set_on_selection_listener(self, "list_view_on_selected")

        self.link = gui.Link("http://localhost:8081", "A link to here", width=200, height=30, margin='10px')

        self.dropDown = gui.DropDown(width=200, height=20, margin='10px')
        c0 = gui.DropDownItem('DropDownItem 0', width=200, height=20)
        c1 = gui.DropDownItem('DropDownItem 1', width=200, height=20)
        self.dropDown.append(c0)
        self.dropDown.append(c1)
        self.dropDown.set_on_change_listener(self, 'drop_down_changed')
        self.dropDown.set_value('DropDownItem 0')

        self.slider = gui.Slider(10, 0, 100, 5, width=200, height=20, margin='10px')
        self.slider.set_on_change_listener(self, 'slider_changed')

        self.colorPicker = gui.ColorPicker('#ffbb00', width=200, height=20, margin='10px')
        self.colorPicker.set_on_change_listener(self, 'color_picker_changed')

        self.date = gui.Date('2015-04-13', width=200, height=20, margin='10px')
        self.date.set_on_change_listener(self, 'date_changed')

        self.video = gui.VideoPlayer('http://www.w3schools.com/tags/movie.mp4',
                                     'http://www.oneparallel.com/wp-content/uploads/2011/01/placeholder.jpg',
                                     width=300, height=270, margin='10px')
        # appending a widget to another, the first argument is a string key
        subContainerRight.append(self.counter)
        subContainerRight.append(self.lbl)
        subContainerRight.append(self.bt)
        subContainerRight.append(self.txt)
        subContainerRight.append(self.spin)
        subContainerRight.append(self.check)
        subContainerRight.append(self.btInputDiag)
        subContainerRight.append(self.btFileDiag)
        # use a defined key as we replace this widget later
        fdownloader = gui.FileDownloader('download test', '../remi/res/logo.png', width=200, height=30, margin='10px')
        subContainerRight.append(fdownloader, key='file_downloader')
        subContainerRight.append(self.btUploadFile)
        subContainerRight.append(self.dropDown)
        subContainerRight.append(self.slider)
        subContainerRight.append(self.colorPicker)
        subContainerRight.append(self.date)
        self.subContainerRight = subContainerRight

        subContainerLeft.append(self.img)
        subContainerLeft.append(self.table)
        subContainerLeft.append(self.listView)
        subContainerLeft.append(self.link)
        subContainerLeft.append(self.video)

        horizontalContainer.append(subContainerLeft)
        horizontalContainer.append(subContainerRight)

        menu = gui.Menu(width='100%', height='30px')
        m1 = gui.MenuItem('File', width=100, height=30)
        m2 = gui.MenuItem('View', width=100, height=30)
        m2.set_on_click_listener(self, 'menu_view_clicked')
        m11 = gui.MenuItem('Save', width=100, height=30)
        m12 = gui.MenuItem('Open', width=100, height=30)
        m12.set_on_click_listener(self, 'menu_open_clicked')
        m111 = gui.MenuItem('Save', width=100, height=30)
        m111.set_on_click_listener(self, 'menu_save_clicked')
        m112 = gui.MenuItem('Save as', width=100, height=30)
        m112.set_on_click_listener(self, 'menu_saveas_clicked')
        m3 = gui.MenuItem('Dialog', width=100, height=30)
        m3.set_on_click_listener(self, 'menu_dialog_clicked')

        menu.append(m1)
        menu.append(m2)
        menu.append(m3)
        m1.append(m11)
        m1.append(m12)
        m11.append(m111)
        m11.append(m112)

        menubar = gui.MenuBar(width='100%', height='30px')
        menubar.append(menu)

        verticalContainer.append(menubar)
        verticalContainer.append(horizontalContainer)

        # kick of regular display of counter
        self.display_counter()

        # returning the root widget
        return verticalContainer
예제 #8
0
 def test_init(self):
     widget = gui.Link(url='http://google.com',
                       text='google')
     assertValidHTML(widget.repr())
     self.assertIn('google', widget.repr())
예제 #9
0
    def main(self):
        # the margin 0px auto centers the main container
        verticalContainer = gui.Container(width=540, margin='0px auto', style={'display': 'block', 'overflow': 'hidden'})

        horizontalContainer = gui.Container(width='100%', layout_orientation=gui.Container.LAYOUT_HORIZONTAL, margin='0px', style={'display': 'block', 'overflow': 'auto'})

        subContainerLeft = gui.Container(width=320, style={'display': 'block', 'overflow': 'auto', 'text-align': 'center'})
        self.img = gui.Image('/res:logo.png', height=100, margin='10px')
        self.img.onclick.do(self.on_img_clicked)

        self.table = gui.Table.new_from_list([('ID', 'First Name', 'Last Name'),
                                              ('101', 'Danny', 'Young'),
                                              ('102', 'Christine', 'Holand'),
                                              ('103', 'Lars', 'Gordon'),
                                              ('104', 'Roberto', 'Robitaille'),
                                              ('105', 'Maria', 'Papadopoulos')], width=300, height=200, margin='10px')
        self.table.on_table_row_click.do(self.on_table_row_click)

        # the arguments are	width - height - layoutOrientationOrizontal
        subContainerRight = gui.Container(style={'width': '220px', 'display': 'block', 'overflow': 'auto', 'text-align': 'center'})
        self.count = 0
        self.counter = gui.Label('', width=200, height=30, margin='10px')

        self.lbl = gui.Label('This is a LABEL!', width=200, height=30, margin='10px')

        self.bt = gui.Button('Press me!', width=200, height=30, margin='10px')
        # setting the listener for the onclick event of the button
        self.bt.onclick.do(self.on_button_pressed)

        self.txt = gui.TextInput(width=200, height=30, margin='10px')
        self.txt.set_text('This is a TEXTAREA')
        self.txt.onchange.do(self.on_text_area_change)

        self.spin = gui.SpinBox(1, 0, 100, width=200, height=30, margin='10px')
        self.spin.onchange.do(self.on_spin_change)

        self.progress = gui.Progress(1, 100, width=200, height=5)

        self.check = gui.CheckBoxLabel('Label checkbox', True, width=200, height=30, margin='10px')
        self.check.onchange.do(self.on_check_change)

        self.btInputDiag = gui.Button('Open InputDialog', width=200, height=30, margin='10px')
        self.btInputDiag.onclick.do(self.open_input_dialog)

        self.btFileDiag = gui.Button('File Selection Dialog', width=200, height=30, margin='10px')
        self.btFileDiag.onclick.do(self.open_fileselection_dialog)

        self.btUploadFile = gui.FileUploader('./', width=200, height=30, margin='10px')
        self.btUploadFile.onsuccess.do(self.fileupload_on_success)
        self.btUploadFile.onfailed.do(self.fileupload_on_failed)

        items = ('Danny Young','Christine Holand','Lars Gordon','Roberto Robitaille')
        self.listView = gui.ListView.new_from_list(items, width=300, height=120, margin='10px')
        self.listView.onselection.do(self.list_view_on_selected)

        self.link = gui.Link("http://localhost:8081", "A link to here", width=200, height=30, margin='10px')

        self.dropDown = gui.DropDown.new_from_list(('DropDownItem 0', 'DropDownItem 1'),
                                                   width=200, height=20, margin='10px')
        self.dropDown.onchange.do(self.drop_down_changed)
        self.dropDown.select_by_value('DropDownItem 0')

        self.slider = gui.Slider(10, 0, 100, 5, width=200, height=20, margin='10px')
        self.slider.onchange.do(self.slider_changed)

        self.colorPicker = gui.ColorPicker('#ffbb00', width=200, height=20, margin='10px')
        self.colorPicker.onchange.do(self.color_picker_changed)

        self.date = gui.Date('2015-04-13', width=200, height=20, margin='10px')
        self.date.onchange.do(self.date_changed)

        self.video = gui.Widget( _type='iframe', width=290, height=200, margin='10px')
        self.video.attributes['src'] = "https://drive.google.com/file/d/0B0J9Lq_MRyn4UFRsblR3UTBZRHc/preview"
        self.video.attributes['width'] = '100%'
        self.video.attributes['height'] = '100%'
        self.video.attributes['controls'] = 'true'
        self.video.style['border'] = 'none'

        self.tree = gui.TreeView(width='100%', height=300)
        ti1 = gui.TreeItem("Item1")
        ti2 = gui.TreeItem("Item2")
        ti3 = gui.TreeItem("Item3")
        subti1 = gui.TreeItem("Sub Item1")
        subti2 = gui.TreeItem("Sub Item2")
        subti3 = gui.TreeItem("Sub Item3")
        subti4 = gui.TreeItem("Sub Item4")
        subsubti1 = gui.TreeItem("Sub Sub Item1")
        subsubti2 = gui.TreeItem("Sub Sub Item2")
        subsubti3 = gui.TreeItem("Sub Sub Item3")
        self.tree.append([ti1, ti2, ti3])
        ti2.append([subti1, subti2, subti3, subti4])
        subti4.append([subsubti1, subsubti2, subsubti3])

        # appending a widget to another, the first argument is a string key
        subContainerRight.append([self.counter, self.lbl, self.bt, self.txt, self.spin, self.progress, self.check, self.btInputDiag, self.btFileDiag])
        # use a defined key as we replace this widget later
        fdownloader = gui.FileDownloader('download test', '../remi/res/logo.png', width=200, height=30, margin='10px')
        subContainerRight.append(fdownloader, key='file_downloader')
        subContainerRight.append([self.btUploadFile, self.dropDown, self.slider, self.colorPicker, self.date, self.tree])
        self.subContainerRight = subContainerRight

        subContainerLeft.append([self.img, self.table, self.listView, self.link, self.video])

        horizontalContainer.append([subContainerLeft, subContainerRight])

        menu = gui.Menu(width='100%', height='30px')
        m1 = gui.MenuItem('File', width=100, height=30)
        m2 = gui.MenuItem('View', width=100, height=30)
        m2.onclick.do(self.menu_view_clicked)
        m11 = gui.MenuItem('Save', width=100, height=30)
        m12 = gui.MenuItem('Open', width=100, height=30)
        m12.onclick.do(self.menu_open_clicked)
        m111 = gui.MenuItem('Save', width=100, height=30)
        m111.onclick.do(self.menu_save_clicked)
        m112 = gui.MenuItem('Save as', width=100, height=30)
        m112.onclick.do(self.menu_saveas_clicked)
        m3 = gui.MenuItem('Dialog', width=100, height=30)
        m3.onclick.do(self.menu_dialog_clicked)

        menu.append([m1, m2, m3])
        m1.append([m11, m12])
        m11.append([m111, m112])

        menubar = gui.MenuBar(width='100%', height='30px')
        menubar.append(menu)

        verticalContainer.append([menubar, horizontalContainer])

        #this flag will be used to stop the display_counter Timer
        self.stop_flag = False

        # kick of regular display of counter
        self.display_counter()

        # returning the root widget
        return verticalContainer
예제 #10
0
파일: widgets.py 프로젝트: pec0ra/buvic
    def __init__(self, settings: Settings):
        super().__init__()

        form_title = Title(Level.H4, "ARF File column")
        self.append(form_title)

        self._arf_selection = gui.DropDown()
        self._arf_selection.append(gui.DropDownItem("1"))
        self._arf_selection.append(gui.DropDownItem("2"))
        self._arf_selection.append(gui.DropDownItem("3"))
        self._arf_selection.append(gui.DropDownItem("4"))
        self._arf_selection.set_value(str(settings.arf_column))
        arf_input = LabeledInput(
            "Column of the ARF file to use for the cos correction (column 0 is sza)",
            self._arf_selection,
            style="margin-bottom: 10px")
        self.append(arf_input)

        form_title = Title(Level.H4, "Daily file settings")
        self.append(form_title)

        self._weighted_irradiance_type_selection = gui.DropDown()
        for t in WeightedIrradianceType:
            self._weighted_irradiance_type_selection.append(
                gui.DropDownItem(t))
        self._weighted_irradiance_type_selection.set_value(
            settings.weighted_irradiance_type)
        weighted_irradiance_type_input = LabeledInput(
            "Type of weight function to use for the weighted irradiance",
            self._weighted_irradiance_type_selection,
            style="margin-bottom: 10px",
        )
        self.append(weighted_irradiance_type_input)

        coscor_title = Title(Level.H4, "Cos correction")
        coscor_title.set_style("margin-top: 14px")
        self.append(coscor_title)

        self._no_coscor_checkbox = gui.CheckBoxLabel("Skip cos correction",
                                                     style="height: 30px")
        self._no_coscor_checkbox.set_value(settings.no_coscor)
        self.append(self._no_coscor_checkbox)

        coscor_title = Title(Level.H4, "Temperature correction")
        coscor_title.set_style("margin-top: 14px")
        self.append(coscor_title)
        temperature_explanation = IconLabel(
            "Each value of the spectrum F for a temperature T (°C) will be corrected with a correction "
            "factor C and a reference temperature Tref (°C) with the formula: F * [1 + C * (T - Tref)]",
            "info_outline",
            style="margin-bottom: 10px",
        )
        self.append(temperature_explanation)

        # Temperature correction dual field
        temp_correction = gui.HBox(
            style="justify-content: stretch; width: 260px")
        self._temp_factor_spin = gui.SpinBox(
            settings.temperature_correction_factor,
            -4,
            4,
            0.01,
            style="width: 100px; height: 25px")
        self._temp_ref_spin = gui.SpinBox(settings.temperature_correction_ref,
                                          -50,
                                          50,
                                          0.5,
                                          style="width: 100px; height: 25px")
        temp_factor_label = gui.Label("C:", style="flex-grow: 1")
        temp_correction.append(temp_factor_label)
        temp_correction.append(self._temp_factor_spin)
        temp_ref_label = gui.Label("Tref:",
                                   style="margin-left: 8px; flex-grow: 1")
        temp_correction.append(temp_ref_label)
        temp_correction.append(self._temp_ref_spin)
        self.append(temp_correction)

        default_title = Title(Level.H4, "Default values")
        default_title.set_style("margin-top: 14px")
        self.append(default_title)
        default_explanation = IconLabel(
            "Will be used if no value is found in the files or via api",
            "info_outline",
            style="margin-bottom: 10px")
        self.append(default_explanation)

        # Albedo field
        self._albedo_spin = gui.SpinBox(settings.default_albedo, 0, 1, 0.01)
        albedo_input = LabeledInput("Albedo",
                                    self._albedo_spin,
                                    style="margin-bottom: 10px")
        self.append(albedo_input)

        # Aerosol dual field
        aerosol = gui.HBox(style="justify-content: stretch; width: 100%")
        self._alpha_spin = gui.SpinBox(settings.default_aerosol.alpha,
                                       0,
                                       2,
                                       0.01,
                                       style="width: 110px; height: 25px")
        self._beta_spin = gui.SpinBox(settings.default_aerosol.beta,
                                      0,
                                      1.5,
                                      0.01,
                                      style="width: 110px; height: 25px")
        alpha_label = gui.Label("α:", style="flex-grow: 1")
        aerosol.append(alpha_label)
        aerosol.append(self._alpha_spin)
        beta_label = gui.Label("β:", style="margin-left: 8px; flex-grow: 1")
        aerosol.append(beta_label)
        aerosol.append(self._beta_spin)
        aerosol_input = LabeledInput("Aerosol",
                                     aerosol,
                                     style="margin-bottom: 10px")
        self.append(aerosol_input)

        # Ozone field
        self._ozone_spin = gui.SpinBox(settings.default_ozone, 200, 600, 0.5)
        ozone_input = LabeledInput("Ozone",
                                   self._ozone_spin,
                                   style="margin-bottom: 10px")
        self.append(ozone_input)

        self._straylight_checkbox = gui.CheckBoxLabel(
            "Apply straylight correction", style="min-height: 30px")
        self._straylight_checkbox.set_value(
            settings.default_straylight_correction ==
            StraylightCorrection.APPLIED)
        self.append(self._straylight_checkbox)

        source_title = Title(Level.H4, "Data source")
        source_title.set_style("margin-top: 14px")
        self.append(source_title)
        source_explanation = IconLabel(
            "Data can either come from files on disk or from the online database eubrewnet.",
            "info_outline",
            style="margin-bottom: 10px; line-height: 14pt",
        )
        self.append(source_explanation)

        self._form_selection_checkbox = gui.CheckBoxLabel(
            "Specify files manually instead of giving a date and a brewer id",
            style="min-height: 30px; margin-bottom: 6px")
        self._form_selection_checkbox.set_value(settings.manual_mode)
        self._form_selection_checkbox.onchange.do(
            lambda w, v: self._update_manual_mode(v))
        self.append(self._form_selection_checkbox)

        self._source_container = VBox()

        self._uv_source_selection = gui.DropDown()
        for source in DataSource:
            self._uv_source_selection.append(gui.DropDownItem(source))
        self._uv_source_selection.set_value(settings.uv_data_source)
        uv_source_input = LabeledInput("UV data source",
                                       self._uv_source_selection,
                                       style="margin-bottom: 10px")
        self._source_container.append(uv_source_input)

        self._ozone_source_selection = gui.DropDown()
        for source in DataSource:
            self._ozone_source_selection.append(gui.DropDownItem(source))
        self._ozone_source_selection.set_value(settings.ozone_data_source)
        ozone_source_input = LabeledInput("Ozone data source",
                                          self._ozone_source_selection,
                                          style="margin-bottom: 10px")
        self._source_container.append(ozone_source_input)

        self._uvr_source_selection = gui.DropDown()
        for source in DataSource:
            self._uvr_source_selection.append(gui.DropDownItem(source))
        self._uvr_source_selection.set_value(settings.uvr_data_source)
        uvr_source_input = LabeledInput("UVR data source",
                                        self._uvr_source_selection,
                                        style="margin-bottom: 10px")
        self._source_container.append(uvr_source_input)

        self._brewer_model_source_selection = gui.DropDown()
        for source in DataSource:
            self._brewer_model_source_selection.append(
                gui.DropDownItem(source))
        self._brewer_model_source_selection.set_value(
            settings.brewer_model_data_source)
        brewer_model_source_input = LabeledInput(
            "Brewer model data source",
            self._brewer_model_source_selection,
            style="margin-bottom: 10px")
        self._source_container.append(brewer_model_source_input)

        self.append(self._source_container)
        self._update_manual_mode(settings.manual_mode)

        woudc_title = Title(Level.H4, "WOUDC output")
        woudc_title.set_style("margin-top: 14px")
        self.append(woudc_title)
        gawsis_link = gui.Link("https://woudc.org/", "WOUDC")
        woudc_explanation = IconLabel(
            "Create files in the WOUDC format which can be submitted to\xa0",
            "info_outline",
            style="margin-bottom: 10px",
        )
        woudc_explanation.append(gawsis_link)

        self.append(woudc_explanation)

        self._woudc_checkbox = gui.CheckBoxLabel(
            "Create WOUDC files", style="min-height: 30px; margin-bottom: 6px")
        self._woudc_checkbox.set_value(settings.activate_woudc)
        self._woudc_checkbox.onchange.do(lambda w, v: self._update_woudc(v))
        self.append(self._woudc_checkbox)

        woudc_info = settings.woudc_info
        self._woudc_info_container = VBox()

        self._agency_input = gui.Input(default_value=woudc_info.agency)
        agency_input = LabeledInput("Agency", self._agency_input)
        self._woudc_info_container.append(agency_input)

        self._version_input = gui.Input(default_value=woudc_info.version)
        version_input = LabeledInput("Version", self._version_input)
        self._woudc_info_container.append(version_input)

        self._scientific_authority_input = gui.Input(
            default_value=woudc_info.scientific_authority)
        scientific_authority_input = LabeledInput(
            "Scientific Authority", self._scientific_authority_input)
        self._woudc_info_container.append(scientific_authority_input)

        self._platform_id_input = gui.Input(
            default_value=woudc_info.platform_id)
        platform_id_input = LabeledInput("Platform ID",
                                         self._platform_id_input)
        self._woudc_info_container.append(platform_id_input)

        self._platform_name_input = gui.Input(
            default_value=woudc_info.platform_name)
        platform_name_input = LabeledInput("Platform Name",
                                           self._platform_name_input)
        self._woudc_info_container.append(platform_name_input)

        self._country_input = gui.Input(default_value=woudc_info.country_iso3)
        country_input = LabeledInput("Country (ISO 3)", self._country_input)
        self._woudc_info_container.append(country_input)

        self._gaw_id_input = gui.Input(default_value=woudc_info.gaw_id)
        gaw_id_input = LabeledInput("GAW Id", self._gaw_id_input)
        self._woudc_info_container.append(gaw_id_input)

        self._altitude_spin = gui.SpinBox(woudc_info.altitude, 0, 6000, 1)
        altitude_input = LabeledInput("Altitude",
                                      self._altitude_spin,
                                      style="margin-bottom: 10px")
        self._woudc_info_container.append(altitude_input)

        self.append(self._woudc_info_container)
        self._update_woudc(settings.activate_woudc)
예제 #11
0
파일: app.py 프로젝트: pec0ra/buvic
    def main(self):

        self._executor = ThreadPoolExecutor(1)

        head: gui.HEAD = self.page.get_child("head")
        head.add_child(
            "google_icons",
            '<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">'
        )
        self._file_utils = FileUtils(DATA_DIR)

        self._main_container = gui.VBox()

        logo_container = gui.HBox()
        logo_container.set_style(
            "width: 100%; justify-content: space-between; margin-bottom: 20px")
        logo = gui.Image("/res:logo_buvic.png",
                         width=300,
                         style="align-self: flex-start")
        header_picture = gui.Image("/res:pmodwrc_logo.png",
                                   width=200,
                                   style="align-self: flex-start")
        logo_container.append(logo)
        logo_container.append(header_picture)
        self._main_container.append(logo_container)

        title = Title(Level.H1, "Brewer UV Irradiance Calculator")

        self._forms = VBox()

        settings_button = IconButton(
            "Settings",
            "settings",
            style="align-self: flex-start; margin-bottom: 10px")
        settings_button.onclick.do(self._open_settings)
        self._forms.append(settings_button)

        self._main_form = SimpleMainForm(self._calculate, self._file_utils,
                                         self._settings, self._handle_error)
        self._secondary_form = PathMainForm(self._calculate, self._settings)
        hide(self._secondary_form)
        self._forms.append(self._main_form)
        self._forms.append(self._secondary_form)

        self._loader = Loader()

        self._result_container = ResultWidget()

        self._main_container.append(title)
        self._main_container.append(self._loader)
        self._main_container.append(self._forms)

        self._error_label = gui.Label(
            "", style="color: #E00; font-size: 12pt; font-weight: bold")
        hide(self._error_label)
        self._main_container.append(self._error_label)

        self._main_container.append(self._result_container)

        version = gui.Link(
            "https://github.com/pec0ra/buvic",
            f"BUVIC {APP_VERSION}",
            style="color: #999; align-self: flex-end; margin-top: 30px")
        self._main_container.append(version)

        self._on_settings_changed()

        self._main_form.refresh()

        # returning the root widget
        return self._main_container
예제 #12
0
    def main(self):
        verticalContainer = gui.Widget(640, 900, gui.Widget.LAYOUT_VERTICAL,
                                       10)

        horizontalContainer = gui.Widget(620, 620,
                                         gui.Widget.LAYOUT_HORIZONTAL, 10)

        subContainerLeft = gui.Widget(340, 530, gui.Widget.LAYOUT_VERTICAL, 10)
        self.img = gui.Image(100, 100, '/res/logo.png')
        self.img.set_on_click_listener(self, 'on_img_clicked')

        self.table = gui.Table(300, 200)
        self.table.from_2d_matrix([['ID', 'First Name', 'Last Name'],
                                   ['101', 'Danny', 'Young'],
                                   ['102', 'Christine', 'Holand'],
                                   ['103', 'Lars', 'Gordon'],
                                   ['104', 'Roberto', 'Robitaille'],
                                   ['105', 'Maria', 'Papadopoulos']])

        # the arguments are	width - height - layoutOrientationOrizontal
        subContainerRight = gui.Widget(240, 560, gui.Widget.LAYOUT_VERTICAL,
                                       10)

        self.count = 0
        self.counter = gui.Label(200, 30, '')

        self.lbl = gui.Label(200, 30, 'This is a LABEL!')

        self.bt = gui.Button(200, 30, 'Press me!')
        # setting the listener for the onclick event of the button
        self.bt.set_on_click_listener(self, 'on_button_pressed')

        self.txt = gui.TextInput(200, 30)
        self.txt.set_text('This is a TEXTAREA')
        self.txt.set_on_change_listener(self, 'on_text_area_change')

        self.spin = gui.SpinBox(200, 30, 100)
        self.spin.set_on_change_listener(self, 'on_spin_change')

        self.check = gui.CheckBoxLabel(200, 30, 'Label checkbox', True)
        self.check.set_on_change_listener(self, 'on_check_change')

        self.btInputDiag = gui.Button(200, 30, 'Open InputDialog')
        self.btInputDiag.set_on_click_listener(self, 'open_input_dialog')

        self.btFileDiag = gui.Button(200, 30, 'File Selection Dialog')
        self.btFileDiag.set_on_click_listener(self,
                                              'open_fileselection_dialog')

        self.btUploadFile = gui.FileUploader(200, 30, './')
        self.btUploadFile.set_on_success_listener(self,
                                                  'fileupload_on_success')
        self.btUploadFile.set_on_failed_listener(self, 'fileupload_on_failed')

        self.listView = gui.ListView(300, 120)
        self.listView.set_on_selection_listener(self, "list_view_on_selected")
        li0 = gui.ListItem(279, 20, 'Danny Young')
        li1 = gui.ListItem(279, 20, 'Christine Holand')
        li2 = gui.ListItem(279, 20, 'Lars Gordon')
        li3 = gui.ListItem(279, 20, 'Roberto Robitaille')
        self.listView.append('0', li0)
        self.listView.append('1', li1)
        self.listView.append('2', li2)
        self.listView.append('3', li3)

        self.link = gui.Link(200, 20, "http://localhost:8081",
                             "A link to here")

        self.dropDown = gui.DropDown(200, 20)
        c0 = gui.DropDownItem(200, 20, 'DropDownItem 0')
        c1 = gui.DropDownItem(200, 20, 'DropDownItem 1')
        self.dropDown.append('0', c0)
        self.dropDown.append('1', c1)
        self.dropDown.set_on_change_listener(self, 'drop_down_changed')
        self.dropDown.set_value('DropDownItem 0')

        self.slider = gui.Slider(200, 20, 10, 0, 100, 5)
        self.slider.set_on_change_listener(self, 'slider_changed')

        self.colorPicker = gui.ColorPicker(200, 20, '#ffbb00')
        self.colorPicker.set_on_change_listener(self, 'color_picker_changed')

        self.date = gui.Date(200, 20, '2015-04-13')
        self.date.set_on_change_listener(self, 'date_changed')

        self.video = gui.VideoPlayer(
            480, 270, 'http://www.w3schools.com/tags/movie.mp4',
            'http://www.oneparallel.com/wp-content/uploads/2011/01/placeholder.jpg'
        )

        # appending a widget to another, the first argument is a string key
        subContainerRight.append('0', self.counter)
        subContainerRight.append('1', self.lbl)
        subContainerRight.append('2', self.bt)
        subContainerRight.append('3', self.txt)
        subContainerRight.append('4', self.spin)
        subContainerRight.append('checkbox', self.check)
        subContainerRight.append('5', self.btInputDiag)
        subContainerRight.append('5_', self.btFileDiag)
        subContainerRight.append(
            '5__',
            gui.FileDownloader(200, 30, 'download test',
                               '../remi/res/logo.png'))
        subContainerRight.append('5___', self.btUploadFile)
        subContainerRight.append('6', self.dropDown)
        subContainerRight.append('7', self.slider)
        subContainerRight.append('8', self.colorPicker)
        subContainerRight.append('9', self.date)
        self.subContainerRight = subContainerRight

        subContainerLeft.append('0', self.img)
        subContainerLeft.append('1', self.table)
        subContainerLeft.append('2', self.listView)
        subContainerLeft.append('3', self.link)
        subContainerLeft.append('4', self.video)

        horizontalContainer.append('0', subContainerLeft)
        horizontalContainer.append('1', subContainerRight)

        menu = gui.Menu(620, 30)
        m1 = gui.MenuItem(100, 30, 'File')
        m2 = gui.MenuItem(100, 30, 'View')
        m2.set_on_click_listener(self, 'menu_view_clicked')
        m11 = gui.MenuItem(100, 30, 'Save')
        m12 = gui.MenuItem(100, 30, 'Open')
        m12.set_on_click_listener(self, 'menu_open_clicked')
        m111 = gui.MenuItem(100, 30, 'Save')
        m111.set_on_click_listener(self, 'menu_save_clicked')
        m112 = gui.MenuItem(100, 30, 'Save as')
        m112.set_on_click_listener(self, 'menu_saveas_clicked')
        m3 = gui.MenuItem(100, 30, 'Dialog')
        m3.set_on_click_listener(self, 'menu_dialog_clicked')

        menu.append('1', m1)
        menu.append('2', m2)
        menu.append('3', m3)
        m1.append('11', m11)
        m1.append('12', m12)
        m11.append('111', m111)
        m11.append('112', m112)

        menubar = gui.MenuBar(620, 30)
        menubar.append('1', menu)

        verticalContainer.append('0', menubar)
        verticalContainer.append('1', horizontalContainer)

        # kick of regular display of counter
        self.display_counter()

        # returning the root widget
        return verticalContainer