Beispiel #1
1
class KDialog(BoxLayout):
    answer_callback = ObjectProperty(p)
    """Функция для обработки событий окна."""
    dismiss_callback = ObjectProperty(p)
    """Функция, которая будет вызвана после закрытия окна."""
    progress_callback = ObjectProperty(None)
    """Функция, вызываемая при появлении окна прогресса."""
    background_color = ListProperty([0.1568627450980392, 0.15294117647058825,
                                     0.15294117647058825, 1.0])
    background_image = StringProperty("atlas://data/images/defaulttheme/"
                                      "modalview-background")
    size_hint_x = NumericProperty(2)
    base_font_size = NumericProperty(15)
    base_font_name = StringProperty("DroidSans")
    title_align = StringProperty("left")
    underline_color = StringProperty("#2fa7d4ff")

    def __init__(self, **kvargs):
        super(KDialog, self).__init__(**kvargs)

        self.orientation = "vertical"
        self.param = None

        # Бокс для кнопок выбора "Да-Нет-Отмена".
        self.box_buttons_select = BoxLayout(orientation="horizontal",
                                            size_hint_y=None, height=40)
        self.scroll = ScrollView()
        self.box_content = GridLayout(cols=2, size_hint_y=None)
        self.box_content.bind(minimum_height=self.box_content.setter("height"))
        self.body = Popup(title_align=self.title_align,
                          background=self.background_image,
                          on_dismiss=self.dismiss_callback)
        # Фон окна сообщения.
        with self.box_content.canvas:
            Color(0.16, 0.16, 0.16)
            self.canvas_for_box_content = \
                Rectangle(pos=(5, 5), size=(self.box_content.width,
                                            self.box_content.height))
            self.box_content.bind(size=self._update_canvas_size,
                                  pos=self._update_canvas_size)

        self.scroll.add_widget(self.box_content)

    def show(self, title="Message:", text="Your text message!",
             text_button_ok=None, text_button_no=None, text_button_cancel=None,
             image="data/logo/kivy-icon-64.png", param="info", password=False,
             auto_dismiss=False, rst=False, size_rst=(.7, .5)):
        """Выводит на экран диалоговые окна."""

        def create_button(name_button):
            """
            type name_button: str;

            """

            button_select = Button(text=name_button, id=name_button)
            button_select.bind(on_press=self._answer_user)
            self.box_buttons_select.add_widget(button_select)

            return True

        try:
            text = text.decode("utf-8")
        except AttributeError:
            pass  # для Python3

        if not rst:
            # Тело текста сообщения.
            self.body.size_hint_y = None
            self.body.size_hint_x = None
            self.body.width = int(Window.size[0] / self.size_hint_x)
        else:
            self.body.size_hint = size_rst

        self.rst = rst
        self.param = param
        button = None

        if len(text) > 6500:
            self.box_content.cols = 1

        if not self.param in ["info", "query", "logpass", "text",
                              "loaddialog"]:
            self.param = "info"

        if self.param == "info":
            auto_dismiss = True
        else:
            for name_button in [text_button_ok, text_button_no,
                                text_button_cancel]:
                if name_button:
                    button = create_button(name_button)

        if self.param == "loaddialog":
            self.message = Label(size_hint_y=None, markup=True, text=text,
                                font_size="{}sp".format(str(self.base_font_size)),
                                font_name=self.base_font_name, valign="middle")
            self.message.bind(size=lambda *args: self._update_label_size(args))
            self.box_content.add_widget(Image(source=image, size_hint_x=None))
            self.box_content.add_widget(self.message)
        else:
            if not rst:
                while text != "":
                    _text = text[:3500]
                    text = text[3500:]
                    # Текстовая информация.
                    self.message = Label(size_hint_y=None, markup=True,
                                         text=_text,
                                         on_ref_press=self.answer_callback,
                                         font_size=self.base_font_size,
                                         font_name=self.base_font_name)
                    self.message.bind(
                        size=lambda *args: self._update_label_size(args))
                    self.box_content.add_widget(self.message)
            else:
                self.message = \
                    RstDocument(text=text, size_hint_y=None,
                                background_color=self.background_color)
                self.box_content.add_widget(self.message)
            self.add_widget(self.scroll)

        if self.param != "query" and self.param != "info" \
                and self.param != "loaddialog":
            if not button:
                create_button("Yes")

            param = self.param
            hint_text = ""

            # FIXME: Виджет TextInput не реагирукет на передаваемые значения
            # параметру input_type, будьто "text", "tel", "address", "mail",
            # "password", "datetime", "number" - в поле ввода отображается
            # только текст.
            if self.param == "logpass":
                hint_text = "Password"
                param = "text"

                self.input_dialog_double = \
                    TextInput(input_type=param, password=password,
                              size_hint_y=None, height=40, hint_text="Login",
                              multiline=False)
                self.input_dialog_double.bind(on_press=self._answer_user)
                self.add_widget(self.input_dialog_double)

            self.add_widget(Widget(size_hint=(None, .03)))
            self.input_dialog = TextInput(input_type=param, password=password,
                                          hint_text=hint_text, multiline=False,
                                          size_hint_y=None, height=40)
            self.input_dialog.bind(on_press=self._answer_user)
            self.add_widget(self.input_dialog)

        if not auto_dismiss or self.param == "query":
            if self.param == "loaddialog":
                self.add_widget(self.scroll)
            else:
                self.add_widget(Widget(size_hint=(None, .03)))
                self.add_widget(SettingSpacer())
                self.add_widget(Widget(size_hint=(None, .03)))
                self.add_widget(self.box_buttons_select)

        self.body.title = title
        self.body.content = self
        self.body.auto_dismiss = auto_dismiss
        self.body.open()

        if self.param == "loaddialog":
            if callable(self.progress_callback):
                Clock.schedule_once(self.progress_callback, 0)

    def _update_label_size(self, *args):
        label = args[0][0]
        label.height = label.texture_size[1]

        if self.param == "loaddialog":
            label.text_size = (label.width - 30, 50)
        else:
            label.text_size = (label.width - 30, None)

        label.texture_update()

    def _update_canvas_size(self, instance, value):
        """Вызывается при изменении размера экрана приложения.

        type instance: instance <kivy.uix.gridlayout.GridLayout object'>;

        type value: list;
        param value: текущий размер instance;

        """

        self.canvas_for_box_content.pos = instance.pos
        self.canvas_for_box_content.size = instance.size

        # Установка размера окна Popup - тела сообщения.
        if self.param in ["text", "tel", "address", "mail", "password",
                          "datetime", "number"]:
            plus_height = 170
        elif self.param == "logpass":
            plus_height = 200
        else:
            plus_height = 120

        self.body.height = self.canvas_for_box_content.size[1] + plus_height
        self.body.width = int(Window.size[0] / self.size_hint_x)

        if self.body.height > Window.size[1]:
            self.body.height = Window.size[1] - 10

        if self.rst:
            self.message.height = self.body.height / 1.33

    def _answer_user(self, *args):
        """Вызывается при нажатии пользователем кнопок диалогового окна."""

        if self.param in ["text", "tel", "address", "mail", "password",
                          "datetime", "number", "logpass"]:
            if self.param == "logpass":
                login = self.input_dialog_double.text
                password = self.input_dialog.text
                self.answer_callback([login, password])
            else:
                self.answer_callback(self.input_dialog.text)
        elif self.param == "query":
            self.answer_callback(args[0].text)

        self.body.dismiss()
Beispiel #2
0
    def get_message(self, *largs):
        box_for_text = self.root.ids.box
        with open('messages.txt', 'r') as f:
            faa = f.readlines()

        with open('messages.txt', 'r') as f:
            fa = f.read()

        if faa == []:
            fa = fa.replace('~', '\n')
            message = RstDocument(text=fa,
                                  size_hint=(None, None),
                                  size=(250, 100),
                                  base_font_size=20,
                                  background_color=(.9, .9, .9, 1))
            box_for_text.add_widget(message)
        else:
            for i in faa:
                i = i.replace('~', '\n')
                if i != '\n':
                    message = RstDocument(text=i,
                                          size_hint=(None, None),
                                          size=(250, 100),
                                          base_font_size=20,
                                          background_color=(.93, .93, .93, 1))
                    box_for_text.add_widget(message)
Beispiel #3
0
 def tab_info(self):
     self.pbuilder = self.parent.parent
     self.description_tab = TabbedPanel()
     particle_info = TabbedPanelHeader(text = 'Particle')
     behavior_info = TabbedPanelHeader(text = 'Behavior')
     color_info = TabbedPanelHeader(text = 'Color')
     particle_info.font_size = self.size[0]*.28
     behavior_info.font_size = self.size[0]*.28
     color_info.font_size = self.size[0]*.28
     particle_info.content = RstDocument(source="param_descriptions/ParticleTab.rst")
     behavior_info.content = RstDocument(source="param_descriptions/BehaviorTab.rst")
     color_info.content = RstDocument(source="param_descriptions/ColorTab.rst")
     particle_info.scroll_distance = 2
     particle_info.scroll_timeout = 500
     behavior_info.scroll_distance = 2
     behavior_info.scroll_timeout = 500
     color_info.scroll_distance = 2
     color_info.scroll_timeout = 500
     self.description_tab.default_tab = particle_info
     self.description_tab.tab_width = self.size[0]*4.36
     self.description_tab.tab_height = self.size[1]*.7
     self.description_tab.add_widget(particle_info)
     self.description_tab.add_widget(behavior_info)
     self.description_tab.add_widget(color_info)
     self.description_popup = Popup(title="Variable Descriptions", content = self.description_tab, size_hint = (.8,.8), on_open=self._popup_opened, on_dismiss=self._popup_dismissed)
     self.description_popup.open()
Beispiel #4
0
    def __init__(self,
                 Doc_Source,
                 Scroll_TargetHeight="Bottom",
                 on_DoubleClick=(lambda: None)):
        RstDocument.__init__(self, text=" ", base_font_size=20)
        self.Doc_Source = Doc_Source
        self.Scroll_TargetHeight = Scroll_TargetHeight

        self.on_DoubleClick = on_DoubleClick
        self.List_ClickTime = []

        self.bind(on_touch_up=self.Check_DoubleClick,
                  on_touch_down=self.Check_DoubleClick)
Beispiel #5
0
    def show_about(self):
        box = BoxLayout(orientation='vertical')
        text = """
        **Monikoo**

        **Version** %s

        Fehlt ein Name, ist eine Information fehlerhaft, oder gibt es
        andere Verbesserungsvorschläge? Dann schreiben sie mir einfach
        eine E-Mail oder kontaktieren mich über Twitter.
        Ich freue mich über jede Rückmeldung.

        **Kontakt**

        %s\n
        %s
        """ % (__version__, __author__, __email__)
        document = RstDocument(text=text, size_hint=(1.,0.9))
        close_button = Button(text=u"Zurück",
        markup=True, size_hint=(1., 0.1),
        background_color=(0.467, 0.286, 1, 0.75))
        box.add_widget(document)
        box.add_widget(close_button)

        popup = BackPopup(title="About",
                    content=box,
                    auto_dismiss = False,
                    title_align = 'center',
                    separator_color=(0.467, 0.286, 1, 0.75))
        close_button.bind(on_press=popup.dismiss)
        self.go_back = popup.go_back
        popup.open()
Beispiel #6
0
    def info(sefl, an_obj):
        name = name_provider.get_by_name(an_obj.id.split('_')[-1])
        if name[1]["gender"].startswith("m"):
            box_color = (0.235, 0.451, 1, 0.75)
        else:
            box_color = (0.847, 0.235, 1, 0.75)

        box = BoxLayout(orientation='vertical')
        text = name_provider.get_rst(name[0], name[1])
        document = RstDocument(text=text, size_hint=(1.,0.9))
        close_button = Button(text=u"Zurück",
        markup=True, size_hint=(1., 0.1),
        background_color=(0.467, 0.286, 1, 0.75))
        box.add_widget(document)
        box.add_widget(close_button)

        popup = Popup(title=name[0],
                    content=box,
                    auto_dismiss = False,
                    title_color = box_color,
                    title_size = '30sp',
                    title_align = 'center',
                    separator_color=(0.467, 0.286, 1, 0.75))
        close_button.bind(on_press=popup.dismiss)
        popup.open()
Beispiel #7
0
    def maineditor(self, *args):
        layout = BoxLayout()
        if self.width < self.height:
            layout.orientation = 'vertical'
        else:
            layout.orientation = 'horizontal'
        #self.bind(self.current_ex=self.update_currentFile)
        man = self.element.manual(self.current_ex)
        codeFile = self.element.readFile(self.current_ex, self.current_file)
        code = CodeInput(text=codeFile)
        code.bind(focus=self.schedule_reload)
        splitter = Splitter()
        if layout.orientation == 'vertical':
            splitter.sizable_from = 'bottom'
        else:
            splitter.sizable_from = 'right'
        splitter.add_widget(code)
        layout.add_widget(splitter)

        if args[0] == 'e':
            layout.add_widget(RstDocument(text=man))
        else:

            layout.add_widget(terminal)
        return layout
Beispiel #8
0
	def __init__(self):
		super(Demo, self).__init__()
		text = """

			<h1>la</h1>
			"""
		document = RstDocument(text=text)
		self.add_widget(document)
Beispiel #9
0
 def load_description(self):
     f = open(os.sep.join([self.demo_path, 'readme.md'])).read()
     description = Popup(title=self.title,
                         size_hint=(None, None),
                         height=500,
                         width=700)
     description.add_widget(RstDocument(text=f))
     description.open()
Beispiel #10
0
    def show_license(self):
        path_to_license = os.path.join(dir, 'assets', 'license_russian.rst')
        if not os.path.exists(path_to_license):
            dialog(text=_('File not found'), title=self.title)
            return

        text_license = open(path_to_license).read()
        widget_license = RstDocument(text=text_license)
        card(widget_license, size=(.9, .8))
Beispiel #11
0
    def __init__(self, screen_manager, localization, description):

        self.sm = screen_manager
        self.l = localization
        popup_width = 600

        title_string = self.l.get_str('Information')
        ok_string = self.l.get_bold('Ok')

        img = Image(source="./asmcnc/apps/shapeCutter_app/img/info_icon.png",
                    allow_stretch=False)
        info_label = RstDocument(text=description,
                                 background_color=[1, 1, 1, 1],
                                 base_font_size=26,
                                 underline_color='000000')

        ok_button = Button(text=ok_string, markup=True)
        ok_button.background_normal = ''
        ok_button.background_color = [76 / 255., 175 / 255., 80 / 255., 1.]

        btn_layout = BoxLayout(orientation='horizontal',
                               spacing=15,
                               padding=[10, 20, 10, 0],
                               size_hint_y=0.6)
        btn_layout.add_widget(ok_button)

        scroll_layout = ScrollView(do_scroll_x=True,
                                   do_scroll_y=True,
                                   scroll_type=['content'],
                                   always_overscroll=True,
                                   size_hint_y=1.2)
        scroll_layout.add_widget(info_label)

        layout_plan = BoxLayout(orientation='vertical',
                                spacing=0,
                                padding=[10, 10, 10, 10])
        layout_plan.add_widget(img)
        layout_plan.add_widget(scroll_layout)
        layout_plan.add_widget(btn_layout)

        popup = Popup(title=title_string,
                      title_color=[0, 0, 0, 1],
                      title_font='Roboto-Bold',
                      title_size='20sp',
                      content=layout_plan,
                      size_hint=(None, None),
                      size=(popup_width, 440),
                      auto_dismiss=False)

        popup.background = './asmcnc/apps/shapeCutter_app/img/popup_background.png'
        popup.separator_color = [249 / 255., 206 / 255., 29 / 255., 1.]
        popup.separator_height = '4dp'

        ok_button.bind(on_press=popup.dismiss)

        popup.open()
Beispiel #12
0
    def view_activity(self):
        self.update_info()
        if self.reward_list.adapter.selection:
            # the selected item name
            selection = self.reward_list.adapter.selection[0].text

            # creating layout in the tab
            content = GridLayout(cols=2)

            col1 = GridLayout(cols=1)
            col1.add_widget(Label(text="Activity Name: " + selection))
            for rewardObject in self.rewarding_list:
                from RRTAA import db_test
                newCode = self.codes.get_new_code()

                if rewardObject[1] == selection:
                    col1.add_widget(
                        Label(text="Date Completed: " + rewardObject[3]))
                    col1.add_widget(
                        Label(text="Amount of Points: " +
                              str(rewardObject[4])))
                    col1.add_widget(Label(text="Code: " + newCode))
                    db_test.update_codes(
                        db_test.con,
                        (rewardObject[5] + '.' + newCode, rewardObject[1]))
                    col1.add_widget(Label(text="Activity Participants: "))
                    simple_list_adapter = SimpleListAdapter(
                        data=rewardObject[6].split('.')[1:], cls=Label)
                    participants = ListView(adapter=simple_list_adapter)
                    col1.add_widget(participants)
                    col1.add_widget(
                        RstDocument(text="Activity Description: " +
                                    rewardObject[2]))

            col2 = GridLayout(cols=2)
            for student in self.grade12_list:
                col2.add_widget(Label(text=student[1]))
                box = CheckBox()
                self.student_checkboxes[student] = box
                col2.add_widget(box)

            # Reward Points Button
            givePoints = Button(text='Reward Points',
                                size_hint_y=None,
                                height=40)
            givePoints.bind(on_press=self.get_active_boxes)
            col1.add_widget(givePoints)

            # adds the layout to the popup tab
            content.add_widget(col1)
            content.add_widget(col2)
            popup = Popup(title=selection,
                          content=content,
                          size_hint=(None, None),
                          size=(800, 500))
            popup.open()
    def build(self):

        _long_text = """
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus odio nisi, pellentesque molestie adipiscing vitae, aliquam at tellus. Fusce quis est ornare erat pulvinar elementum ut sed felis. Donec vel neque mauris. In sit amet nunc sit amet diam dapibus lacinia. In sodales placerat mauris, ut euismod augue laoreet at. Integer in neque non odio fermentum volutpat nec nec nulla. Donec et risus non mi viverra posuere. Phasellus cursus augue purus, eget volutpat leo. Phasellus sed dui vitae ipsum mattis facilisis vehicula eu justo.

        Quisque neque dolor, egestas sed venenatis eget, porta id ipsum. Ut faucibus, massa vitae imperdiet rutrum, sem dolor rhoncus magna, non lacinia nulla risus non dui. Nulla sit amet risus orci. Nunc libero justo, interdum eu pulvinar vel, pulvinar et lectus. Phasellus sed luctus diam. Pellentesque non feugiat dolor. Cras at dolor velit, gravida congue velit. Aliquam erat volutpat. Nullam eu nunc dui, quis sagittis dolor. Ut nec dui eget odio pulvinar placerat. Pellentesque mi metus, tristique et placerat ac, pulvinar vel quam. Nam blandit magna a urna imperdiet molestie. Nullam ut nisi eget enim laoreet sodales sit amet a felis.
        """

        reallyLongText = _long_text + _long_text + _long_text + _long_text + _long_text
        return RstDocument(text=reallyLongText)
Beispiel #14
0
    def __init__(self, **kwargs):
        super(StudyScreen, self).__init__(**kwargs)

        # Create a float layout.
        self.float_layout = FloatLayout()
        self.add_widget(self.float_layout)

        # Add the right side of the screen, where we will show the text.
        self.rst_document = RstDocument(source="assets/chapters/chapter01.rst",
                                        show_errors=True,
                                        size_hint=(0.8, 1),
                                        pos_hint={"right":1, "top":1})
        self.float_layout.add_widget(self.rst_document)

        # Add the dropdown "menu" at the left of the screen.
        self.dropdown = DropDown()
        for chapter in ['01', '02', '03']:
            # when adding widgets, we need to specify the height manually (disabling
            # the size_hint_y) so the dropdown can calculate the area it needs.
            btn = PurpleRoundedButton(text=chapter,
                                      height=400,
                                      #height=0.2,
                                      size_hint_y=None)

            # For each button, attach a callback that will call the select() method
            # on the dropdown. We'll pass the text of the button as the data of the
            # selection.
            btn.bind(on_release=lambda btn: self.dropdown.select(btn.text))
            # Add another bind so the RST document is updated according to the selection.
            btn.bind(on_press=lambda btn: self.update_study_text(btn.text))

            # Add the button inside the dropdown.
            self.dropdown.add_widget(btn)

        # Create a big main button to open the dropdown.
        self.mainbutton = PurpleRoundedButton(text='Lessons',
                                              size_hint=(0.2, 0.2),
                                              pos_hint={"left":0, "top":1})

        # Show the dropdown menu when the main button is released
        # note: all the bind() calls pass the instance of the caller (here, the
        # mainbutton instance) as the first argument of the callback (here,
        # dropdown.open).
        self.mainbutton.bind(on_release=self.dropdown.open)

        # Listen for the selection in the dropdown list and
        # assign the data to the button text.
        self.dropdown.bind(on_select=lambda instance, x: setattr(self.mainbutton, 'text', x))
        self.float_layout.add_widget(self.mainbutton)

        # Add a button explaining how to use this section.
        self.study_instructions_button = InstructionsButton(pos_hint={"center_x": 0.1, "bottom": 1})
        self.study_instructions_button.bind(on_press=self.show_instructions)
        self.float_layout.add_widget(self.study_instructions_button)
Beispiel #15
0
        def view_details(_):
            details = Popup(size_hint=(.8, .8), title=self.character.race)
            race = (session.query(Race).filter(
                Race.name == self.character.race).scalar())
            if race:
                text = race.details
            else:
                text = "Race '%s' not found" % self.character.race

            details.add_widget(RstDocument(text=text))
            details.open()
Beispiel #16
0
        def view_details(_):
            details = Popup(size_hint=(.8, .8), title=self.character.class_)
            class_ = (session.query(Class).filter(
                Class.name == self.character.class_).scalar())
            if class_:
                text = class_.details
            else:
                text = "Class_ '%s' not found" % self.character.class_

            details.add_widget(RstDocument(text=text))
            details.open()
Beispiel #17
0
        def view_details(_):
            monster_type = self.monster.monster_type or ''
            details = Popup(size_hint=(.8, .8), title=monster_type)
            monster_type = (session.query(Monster).filter(
                Monster.name == monster_type).scalar())
            if monster_type:
                text = monster_type.get_details()
            else:
                text = "Monster_Type '%s' not found" % monster_type

            details.add_widget(RstDocument(text=text))
            details.open()
Beispiel #18
0
 def popup_readme(self):
     readme_path = os.sep.join([
         self.bundle_dir, 'plugins', 'processing', 'model_zoo', 'models',
         self.id, 'README.md'
     ])
     f = open(readme_path).read()
     description = Popup(title=self.title,
                         size_hint=(None, None),
                         height=500,
                         width=700)
     description.add_widget(RstDocument(text=f))
     description.open()
Beispiel #19
0
    def __init__(self, screen_manager):

        self.shapecutter_sm = screen_manager

        ok_button = Button(text='[b]Ok[/b]', markup=True)
        ok_button.background_normal = ''
        ok_button.background_color = [76 / 255., 175 / 255., 80 / 255., 1.]

        btn_layout = BoxLayout(orientation='horizontal',
                               spacing=15,
                               padding=[150, 0, 150, 0],
                               size_hint_y=0.2)
        btn_layout.add_widget(ok_button)

        rst_doc = RstDocument(
            source='./asmcnc/apps/shapeCutter_app/feeds_and_speeds_table.rst',
            background_color=[1, 1, 1, 1],
            base_font_size=26,
            underline_color='000000')

        rst_layout = ScrollView(do_scroll_x=True,
                                do_scroll_y=True,
                                scroll_type=['content'],
                                size_hint_y=0.8)
        rst_layout.add_widget(rst_doc)

        layout_plan = BoxLayout(orientation='vertical',
                                spacing=10,
                                padding=[10, 10, 10, 10])
        layout_plan.add_widget(rst_layout)
        layout_plan.add_widget(btn_layout)

        popup = Popup(
            title='Information',
            #                       title_color=[0.141, 0.596, 0.957, 1],
            title_color=[0, 0, 0, 1],
            title_font='Roboto-Bold',
            title_size='20sp',
            content=layout_plan,
            size_hint=(None, None),
            size=(700, 400),
            auto_dismiss=False)

        popup.background = './asmcnc/apps/shapeCutter_app/img/popup_background.png'
        popup.separator_color = [249 / 255., 206 / 255., 29 / 255., 1.]
        popup.separator_height = '4dp'

        ok_button.bind(on_press=popup.dismiss)
        popup.open()
Beispiel #20
0
 def __init__(self,
              text,
              title='Details',
              size_hint=(.8, .8),
              *args,
              **kwargs):
     content = BoxLayout(orientation='vertical')
     content.add_widget(RstDocument(text=text))
     self.title = title
     content.add_widget(
         Button(text='Continue', on_press=self.dismiss, size_hint=(1, .2)))
     super(DetailPopup, self).__init__(content=content,
                                       size_hint=size_hint,
                                       *args,
                                       **kwargs)
Beispiel #21
0
        def show_license(dialog, on_language):
            path_to_license = '{}/license/license_{}.rst'.format(
                self.directory, self.data.dict_language[on_language])
            if not os.path.exists(path_to_license):
                dialog(text=self.data.string_lang_not_license,
                       title=self.title)
                dialog.dismiss()

                return

            text_license = open(path_to_license).read()
            widget_license = RstDocument(
                text=text_license,
                background_color=self.data.alpha,
                underline_color=self.data.underline_rst_color)
            card(widget_license, size=(.9, .8))
            dialog.dismiss()
Beispiel #22
0
 def MAJ(self):
     if self.MAJeffectuee == True :
         return
     listeOnglets = []
     for titre, texte in LISTE_TEXTES :
         #onglet = TabbedPanelItem(text=titre)
         #doc = RstDocument(text=texte)
         #onglet.add_widget(doc)
         
         onglet = TabbedPanelHeader(text=titre)
         onglet.font_size = 15
         onglet.content = RstDocument(text=texte)
   
         
         self.tab_aide.add_widget(onglet)
         listeOnglets.append(onglet)
     self.tab_aide.switch_to(listeOnglets[0])
     self.MAJeffectuee = True
        def show_license(progress, on_language):
            path_to_license = '{}/license/license_{}.rst'.format(
                os.getcwd(), basis.dict_language[on_language])

            if not os.path.exists(path_to_license):
                MyPopup(title=basis.string_lang_title).show(
                    text=basis.string_lang_not_license,
                    text_button_ok=basis.string_lang_yes)
                progress.dismiss()

            text_license = codecs.open(path_to_license, 'r', 'utf-8').read()
            view = ModalView(size_hint=(None, None),
                             size=(Window.width - dp(30),
                                   Window.height - dp(70)))
            view.add_widget(
                RstDocument(text=text_license, effect_cls=ScrollEffect))
            view.open()
            progress.dismiss()
Beispiel #24
0
    def _show_info_plugin(self, name_plugin):
        '''Вызывается при клике на имя плагина из списка.'''

        if not os.path.exists('{}/libs/plugins/{}/README.rst'.format(
                self.directory, name_plugin)):
            dialog(text=self.translation._(u'Нет информации о плагине!'),
                   title=name_plugin)
        else:
            info_plugin = open('{}/libs/plugins/{}/README.rst'.format(
                self.directory, name_plugin)).read()
            info_plugin = info_plugin.format(
                NAME_APP=self.title,
                VERSION=self.started_plugins[name_plugin]['plugin-version'],
                AUTHOR=self.started_plugins[name_plugin]['plugin-author'],
                MAIL=self.started_plugins[name_plugin]['plugin-mail'],
            )
            # TODO: избавиться от использования RstDocument.
            widget_info = RstDocument(text=info_plugin,
                                      background_color=self.alpha,
                                      underline_color=self.underline_rst_color)
            card(widget_info, size=(.75, .6))
Beispiel #25
0
        def setActive(selected):
            if selected > -1:
                global shoppingList
                shoppingList['active'] = selected
                populate()
                writeFile(0)
            else:

                with open(scriptDir + '/ABOUT.rst') as fd:
                    about = fd.read()

                with open(scriptDir + '/LICENSE') as fd:
                    license = fd.read()

                aboutText = RstDocument(text=about +
                                        '\n\nLicense\n-------\n\n' + license, )
                popup = Popup(
                    title="Plocka " + __version__,
                    content=aboutText,
                )
                popup.open()
Beispiel #26
0
    def _show_info_plugin(self, name_plugin):
        '''Вызывается при клике на имя плагина из списка.'''

        if not os.path.exists('{}/libs/plugins/{}/README.rst'.format(
                self.directory, name_plugin)):
            dialog(
                text=self.data.string_lang_not_info_plugin, title=name_plugin
            )
        else:
            info_plugin = open('{}/libs/plugins/{}/README.rst'.format(
                self.directory, name_plugin)).read()
            info_plugin = info_plugin.format(
                NAME_APP=self.title,
                VERSION=self.started_plugins[name_plugin]['plugin-version'],
                AUTHOR=self.started_plugins[name_plugin]['plugin-author'],
                MAIL=self.started_plugins[name_plugin]['plugin-mail'],
            )
            widget_info = RstDocument(
                text=info_plugin, background_color=self.data.alpha,
                underline_color=self.data.underline_rst_color
            )
            card(widget_info, size=(.75, .6))
Beispiel #27
0
    def __init__(self, font_size=FONT_MEDIUM, *args, **kwargs):
        super(EncountersTab, self).__init__(font_size=font_size,
                                            *args,
                                            **kwargs)

        self.text = 'Encounters'

        content = BoxLayout(orientation='vertical')

        self.encounter = session.query(Encounter).first()

        rendered = RstDocument(
            text=self.encounter.description,
            background_color=BLACK,
            colors=dict(paragraph='eeeeee',
                        background='000000',
                        title='eeeeee',
                        link='666666'),
        )

        def edit_content(value):
            self.encounter.description = value
            self.encounter = session.merge(self.encounter)
            session.commit()
            rendered.text = value

        def open_editor(instance):
            editor = TextPromptPopup('Edit encounter',
                                     callback=edit_content,
                                     text=rendered.text)
            editor.open()

        content.add_widget(rendered)

        content.add_widget(
            Button(text='Edit', size_hint=(1, .1), on_press=open_editor))

        self.add_widget(content)
Beispiel #28
0
    def __init__(self, character, *args, **kwargs):
        super(BackstoryTab, self).__init__(*args, **kwargs)

        character.backstory = character.backstory or ''
        self.character = character
        self.text = 'Notes'

        content = BoxLayout(orientation='vertical')

        rendered = RstDocument(
            text=character.backstory,
            background_color=BLACK,
            colors=dict(paragraph='eeeeee',
                        background='000000',
                        title='eeeeee',
                        link='666666'),
        )

        def edit_content(value):
            self.character.backstory = value
            self.character = session.merge(character)
            session.commit()
            rendered.text = value

        def open_editor(_):
            editor = TextPromptPopup('Edit backstory',
                                     callback=edit_content,
                                     text=rendered.text)
            editor.open()

        content.add_widget(rendered)

        content.add_widget(
            Button(text='Edit', size_hint=(1, .1), on_press=open_editor))

        self.add_widget(content)
Beispiel #29
0
    def show(self, title="Message:", text="Your text message!",
             text_button_ok=None, text_button_no=None, text_button_cancel=None,
             image="data/logo/kivy-icon-64.png", param="info", password=False,
             auto_dismiss=False, rst=False, size_rst=(.7, .5)):
        """Выводит на экран диалоговые окна."""

        def create_button(name_button):
            """
            type name_button: str;

            """

            button_select = Button(text=name_button, id=name_button)
            button_select.bind(on_press=self._answer_user)
            self.box_buttons_select.add_widget(button_select)

            return True

        try:
            text = text.decode("utf-8")
        except AttributeError:
            pass  # для Python3

        if not rst:
            # Тело текста сообщения.
            self.body.size_hint_y = None
            self.body.size_hint_x = None
            self.body.width = int(Window.size[0] / self.size_hint_x)
        else:
            self.body.size_hint = size_rst

        self.rst = rst
        self.param = param
        button = None

        if len(text) > 6500:
            self.box_content.cols = 1

        if not self.param in ["info", "query", "logpass", "text",
                              "loaddialog"]:
            self.param = "info"

        if self.param == "info":
            auto_dismiss = True
        else:
            for name_button in [text_button_ok, text_button_no,
                                text_button_cancel]:
                if name_button:
                    button = create_button(name_button)

        if self.param == "loaddialog":
            self.message = Label(size_hint_y=None, markup=True, text=text,
                                font_size="{}sp".format(str(self.base_font_size)),
                                font_name=self.base_font_name, valign="middle")
            self.message.bind(size=lambda *args: self._update_label_size(args))
            self.box_content.add_widget(Image(source=image, size_hint_x=None))
            self.box_content.add_widget(self.message)
        else:
            if not rst:
                while text != "":
                    _text = text[:3500]
                    text = text[3500:]
                    # Текстовая информация.
                    self.message = Label(size_hint_y=None, markup=True,
                                         text=_text,
                                         on_ref_press=self.answer_callback,
                                         font_size=self.base_font_size,
                                         font_name=self.base_font_name)
                    self.message.bind(
                        size=lambda *args: self._update_label_size(args))
                    self.box_content.add_widget(self.message)
            else:
                self.message = \
                    RstDocument(text=text, size_hint_y=None,
                                background_color=self.background_color)
                self.box_content.add_widget(self.message)
            self.add_widget(self.scroll)

        if self.param != "query" and self.param != "info" \
                and self.param != "loaddialog":
            if not button:
                create_button("Yes")

            param = self.param
            hint_text = ""

            # FIXME: Виджет TextInput не реагирукет на передаваемые значения
            # параметру input_type, будьто "text", "tel", "address", "mail",
            # "password", "datetime", "number" - в поле ввода отображается
            # только текст.
            if self.param == "logpass":
                hint_text = "Password"
                param = "text"

                self.input_dialog_double = \
                    TextInput(input_type=param, password=password,
                              size_hint_y=None, height=40, hint_text="Login",
                              multiline=False)
                self.input_dialog_double.bind(on_press=self._answer_user)
                self.add_widget(self.input_dialog_double)

            self.add_widget(Widget(size_hint=(None, .03)))
            self.input_dialog = TextInput(input_type=param, password=password,
                                          hint_text=hint_text, multiline=False,
                                          size_hint_y=None, height=40)
            self.input_dialog.bind(on_press=self._answer_user)
            self.add_widget(self.input_dialog)

        if not auto_dismiss or self.param == "query":
            if self.param == "loaddialog":
                self.add_widget(self.scroll)
            else:
                self.add_widget(Widget(size_hint=(None, .03)))
                self.add_widget(SettingSpacer())
                self.add_widget(Widget(size_hint=(None, .03)))
                self.add_widget(self.box_buttons_select)

        self.body.title = title
        self.body.content = self
        self.body.auto_dismiss = auto_dismiss
        self.body.open()

        if self.param == "loaddialog":
            if callable(self.progress_callback):
                Clock.schedule_once(self.progress_callback, 0)
Beispiel #30
0
    def show(self, text='Your text message!', check_text='', hint_text='',
             rst=False, check=False, text_button_ok=None, text_button_no=None,
             text_button_cancel=None, image=None, param='info', password=False,
             auto_dismiss=True):
        '''
        :param hint_text: текст по умолчанию в поле ввода;
        :type hint_text: str;

        :param text: текст окна;
        :type text: str;

        :param check_text: текст чекбокса;
        :type check_text: str;

        :param text_button_ok: текст кнопки;
        :type text_button_ok: str;

        :param text_button_no:
        :type text_button_no: str;

        :param text_button_cancel:
        :type text_button_cancel: str;

        :param image: путь к иконке заргузки при параметре окна 'loaddialog';
        :type image: str;

        :param param: тип окна;
        :type param: str;

        :param password: скрывать ли вводимый текст звездочками
                         при параметре окна 'password';
        :type password: boolean;

        :param auto_dismiss: автоматически скрывать окно;
        :type auto_dismiss: boolean;

        :param rst: выводить текст на виджет RstDocument;
        :type rst: boolean;

        :param check: использовать ли в окне чекбос;
        :type check: boolean;

        '''

        def create_button(name_button, background_image_normal,
                          background_image_down):
            self.box_buttons_select.add_widget(
                Button(text=name_button, id=name_button,
                       background_normal=background_image_normal,
                       background_down=background_image_down,
                       on_release=self._answer_user)
            )
            return True

        self.rst = rst
        self.check = check
        self.param = param
        button = None

        if not image:
            image = '{}/data/loading.gif'.format(self.root)
        if self.param not in [
                'info', 'query', 'logpass', 'text', 'loaddialog']:
            self.param = 'info'

        for i, name_button in enumerate(
                [text_button_ok, text_button_no, text_button_cancel]):
            if name_button:
                button = create_button(
                    name_button, self.background_image_buttons[i],
                    self.background_image_shadows[i]
                )

        if self.param == 'loaddialog':
            self.box_content.cols = 2
            self.message = \
                Label(size_hint_y=None, markup=True, text=text,
                      font_size=self.sp(self.base_font_size),
                      font_name=self.base_font_name, valign='middle')
            self.message.bind(size=lambda *args: self._update_label_size(args))
            self.box_content.add_widget(Image(source=image, size_hint_x=None))
            self.box_content.add_widget(self.message)
        else:
            if not rst:
                while text != '':
                    _text = text[:3500]
                    text = text[3500:]
                    # Текстовая информация.
                    self.message = \
                        Label(size_hint_y=None, markup=True, text=_text,
                              on_ref_press=self.answer_callback,
                              font_size=self.sp(self.base_font_size),
                              font_name=self.base_font_name)
                    self.message.bind(
                        size=lambda *args: self._update_label_size(args)
                    )
                    self.box_content.add_widget(self.message)
            else:
                self.message = RstDocument(
                    text=text, size_hint_y=None, height=self.dp(400),
                    background_color=[1.0, 1.0, 1.0, 0.0]
                )
                self.box_content.add_widget(self.message)

        if self.param not in ['query', 'info', 'loaddialog']:
            param = self.param

            # FIXME: Виджет TextInput не реагирует на значения аргументов
            # 'tel', 'address', 'mail', 'datetime', 'number'.
            if self.param == 'logpass':
                param = 'text'
                hint_text = 'Password'

                self.input_dialog_double = \
                    TextInput(input_type=param, password=password,
                              size_hint_y=None, height=self.dp(40),
                              hint_text='Login', multiline=False,
                              background_normal=self.text_input,
                              background_active=self.text_input)
                self.input_dialog_double.bind(on_press=self._answer_user)
                self.box_root.add_widget(self.input_dialog_double)

            self.box_root.add_widget(Widget(size_hint=(None, .03)))
            self.input_dialog = \
                TextInput(input_type=param, password=password,
                          hint_text=hint_text, multiline=False,
                          size_hint_y=None, height=self.dp(40),
                          background_normal=self.text_input,
                          background_active=self.text_input)
            self.input_dialog.bind(on_press=self._answer_user)
            self.box_root.add_widget(self.input_dialog)

        if self.param == 'query':
            if check:
                box_check = BoxLayout(size_hint_y=None, height=self.dp(40))
                label_check = Label(
                    id='check', text=check_text, size_hint=(1, None),
                    font_size=self.sp(self.base_font_size),
                    font_name=self.base_font_name, markup=True, height=18
                )
                label_check.bind(
                    size=lambda *args: self._update_label_size(args)
                )
                self.checkbox = CheckBox(
                    active=False, size_hint_y=.5, size_hint_x=.1,
                    background_checkbox_normal=self.checkbox_normal,
                    background_checkbox_down=self.checkbox_down
                )

                box_check.add_widget(self.checkbox)
                box_check.add_widget(label_check)
                self.box_root.add_widget(box_check)

        if not button and self.param in ['query', 'text', 'logpass']:
            create_button(
                'OK', self.background_image_buttons[0],
                self.background_image_shadows[0]
            )
        if self.param in ['query', 'text', 'logpass']:
            self.box_root.add_widget(Widget(size_hint=(None, .03)))
            self.box_root.add_widget(SettingSpacer())
            self.box_root.add_widget(Widget(size_hint=(None, .03)))
            self.box_root.add_widget(self.box_buttons_select)

        self.auto_dismiss = auto_dismiss
        self._update_box_content_size()
        self.open()

        if self.param == 'loaddialog':
            if callable(self.progress_callback):
                Clock.schedule_once(self.progress_callback, 0)
        return self
Beispiel #31
0
    def show(self,
             text='Your text message!',
             check_text='',
             hint_text='',
             rst=False,
             check=False,
             text_button_ok=None,
             text_button_no=None,
             text_button_cancel=None,
             image=None,
             param='info',
             password=False,
             auto_dismiss=True):
        '''
        :param hint_text: текст по умолчанию в поле ввода;
        :type hint_text: str;

        :param text: текст окна;
        :type text: str;

        :param check_text: текст чекбокса;
        :type check_text: str;

        :param text_button_ok: текст кнопки;
        :type text_button_ok: str;

        :param text_button_no:
        :type text_button_no: str;

        :param text_button_cancel:
        :type text_button_cancel: str;

        :param image: путь к иконке заргузки при параметре окна 'loaddialog';
        :type image: str;

        :param param: тип окна;
        :type param: str;

        :param password: скрывать ли вводимый текст звездочками
                         при параметре окна 'password';
        :type password: boolean;

        :param auto_dismiss: автоматически скрывать окно;
        :type auto_dismiss: boolean;

        :param rst: выводить текст на виджет RstDocument;
        :type rst: boolean;

        :param check: использовать ли в окне чекбос;
        :type check: boolean;

        '''
        def create_button(name_button, background_image_normal,
                          background_image_down):
            self.box_buttons_select.add_widget(
                Button(text=name_button,
                       id=name_button,
                       background_normal=background_image_normal,
                       background_down=background_image_down,
                       on_release=self._answer_user))
            return True

        self.rst = rst
        self.check = check
        self.param = param
        button = None

        if not image:
            image = '{}/data/loading.gif'.format(self.root)
        if self.param not in [
                'info', 'query', 'logpass', 'text', 'loaddialog'
        ]:
            self.param = 'info'

        for i, name_button in enumerate(
            [text_button_ok, text_button_no, text_button_cancel]):
            if name_button:
                button = create_button(name_button,
                                       self.background_image_buttons[i],
                                       self.background_image_shadows[i])

        if self.param == 'loaddialog':
            self.box_content.cols = 2
            self.message = \
                Label(size_hint_y=None, markup=True, text=text,
                      font_size=self.sp(self.base_font_size),
                      font_name=self.base_font_name, valign='middle')
            self.message.bind(size=lambda *args: self._update_label_size(args))
            self.box_content.add_widget(Image(source=image, size_hint_x=None))
            self.box_content.add_widget(self.message)
        else:
            if not rst:
                while text != '':
                    _text = text[:3500]
                    text = text[3500:]
                    # Текстовая информация.
                    self.message = \
                        Label(size_hint_y=None, markup=True, text=_text,
                              on_ref_press=self.answer_callback,
                              font_size=self.sp(self.base_font_size),
                              font_name=self.base_font_name)
                    self.message.bind(
                        size=lambda *args: self._update_label_size(args))
                    self.box_content.add_widget(self.message)
            else:
                self.message = RstDocument(
                    text=text,
                    size_hint_y=None,
                    height=self.dp(400),
                    background_color=[1.0, 1.0, 1.0, 0.0])
                self.box_content.add_widget(self.message)

        if self.param not in ['query', 'info', 'loaddialog']:
            param = self.param

            # FIXME: Виджет TextInput не реагирует на значения аргументов
            # 'tel', 'address', 'mail', 'datetime', 'number'.
            if self.param == 'logpass':
                param = 'text'
                hint_text = 'Password'

                self.input_dialog_double = \
                    TextInput(input_type=param, password=password,
                              size_hint_y=None, height=self.dp(40),
                              hint_text='Login', multiline=False,
                              background_normal=self.text_input,
                              background_active=self.text_input)
                self.input_dialog_double.bind(on_press=self._answer_user)
                self.box_root.add_widget(self.input_dialog_double)

            self.box_root.add_widget(Widget(size_hint=(None, .03)))
            self.input_dialog = \
                TextInput(input_type=param, password=password,
                          hint_text=hint_text, multiline=False,
                          size_hint_y=None, height=self.dp(40),
                          background_normal=self.text_input,
                          background_active=self.text_input)
            self.input_dialog.bind(on_press=self._answer_user)
            self.box_root.add_widget(self.input_dialog)

        if self.param == 'query':
            if check:
                box_check = BoxLayout(size_hint_y=None, height=self.dp(40))
                label_check = Label(id='check',
                                    text=check_text,
                                    size_hint=(1, None),
                                    font_size=self.sp(self.base_font_size),
                                    font_name=self.base_font_name,
                                    markup=True,
                                    height=18)
                label_check.bind(
                    size=lambda *args: self._update_label_size(args))
                self.checkbox = CheckBox(
                    active=False,
                    size_hint_y=.5,
                    size_hint_x=.1,
                    background_checkbox_normal=self.checkbox_normal,
                    background_checkbox_down=self.checkbox_down)

                box_check.add_widget(self.checkbox)
                box_check.add_widget(label_check)
                self.box_root.add_widget(box_check)

        if not button and self.param in ['query', 'text', 'logpass']:
            create_button('OK', self.background_image_buttons[0],
                          self.background_image_shadows[0])
        if self.param in ['query', 'text', 'logpass']:
            self.box_root.add_widget(Widget(size_hint=(None, .03)))
            self.box_root.add_widget(SettingSpacer())
            self.box_root.add_widget(Widget(size_hint=(None, .03)))
            self.box_root.add_widget(self.box_buttons_select)

        self.auto_dismiss = auto_dismiss
        self._update_box_content_size()
        self.open()

        if self.param == 'loaddialog':
            if callable(self.progress_callback):
                Clock.schedule_once(self.progress_callback, 0)
        return self
Beispiel #32
0
 def get_rst_doc(self, doc):
     """a crash happened on android when using a KV file or importing at the top"""
     from kivy.uix.rst import RstDocument
     return RstDocument(source=doc)
Beispiel #33
0
 def build(self):
     return RstDocument(text=__doc__)