예제 #1
0
class ConsoleHistoryItem:
    def __init__(self, history, text, color = "font_color_entry"):
        self.history_entry = LUIFormattedLabel(margin = (0, 0, 0, 0),
                                               #padding = 10,
                                               #color=(0.4,0.0,0.0, 1.0),
                                               )
        history.add(self.history_entry)
        self.history_entry.solid = True
        self.history_entry.bind("click", self.click)

        # FIXME: Choose color based on text_type
        for text_part in text.split("\n"):
            if text_part == "":
                self.history_entry.newline()
            else:
                self.history_entry.add(text_part, font_size = 15, color = colors[color])
                self.history_entry.newline()
        
        self.text = text
        self.original_color = color
        self.selected = False
        
    def click(self, lui_event):
        #print("click!")
        #print("  " + str(lui_event.name))        # click
        #print("  " + str(lui_event.sender))      # <lui.LUIObject object at 0x7f1a3eb66eb8>
        #print("  " + str(lui_event.coordinates)) # LPoint2f(58, 36)
        #print("  " + str(lui_event.message))     #
        self.selected = not self.selected
        if self.selected:
            self.history_entry.color = colors["font_color_selected_history_item"]
            print(colors["font_color_selected_history_item"])
        else:
            self.history_entry.color = colors[self.original_color]
            print(colors[self.original_color])
예제 #2
0
    def construct_sourcecode(self, classname):
        self._source_content.remove_all_children()
        label = LUIFormattedLabel(parent=self._source_content)
        label.add(text="element ", color=(0.9, 0.9, 0.9))
        label.add(text="= ", color=(249 / 255.0, 38 / 255.0, 114 / 255.0))
        label.add(text=classname, color=(166 / 255.0, 226 / 255.0, 46 / 255.0))
        label.add(text="(", color=(0.9, 0.9, 0.9))

        for index, (pname, pvalue) in enumerate(self._constructor_params):
            label.newline()
            label.add(text=" " * 15)
            label.add(text=pname, color=(255 / 255.0, 151 / 255.0, 31 / 255.0))
            label.add(text=" = ")
            label.add(text=pvalue,
                      color=(153 / 255.0, 129 / 255.0, 255 / 255.0))

            if index < len(self._constructor_params) - 1:
                label.add(text=",")

        label.add(text=")")

        copy_text = "element = " + classname + "("

        for index, (pname, pvalue) in enumerate(self._constructor_params):
            copy_text += pname + "=" + pvalue

            if index < len(self._constructor_params) - 1:
                copy_text += ", "
        copy_text += ")"

        def copy_code(event):
            # Copies the source code to clipboard
            from Tkinter import Tk
            r = Tk()
            r.withdraw()
            r.clipboard_clear()
            r.clipboard_append(copy_text)
            r.destroy()

        self._copy_code_button.bind("click", copy_code)

        # self._source_content.fit_height_to_children()
        # self._source_container.fit_height_to_children()
        self._source_container.height += 40
예제 #3
0
    def construct_sourcecode(self, classname):
        self._source_content.remove_all_children()
        label = LUIFormattedLabel(parent=self._source_content)
        label.add(text="element ", color=(0.9,0.9,0.9))
        label.add(text="= ", color=(249/255.0, 38/255.0, 114/255.0))
        label.add(text=classname, color=(166/255.0, 226/255.0, 46/255.0))
        label.add(text="(", color=(0.9,0.9,0.9))

        for index, (pname, pvalue) in enumerate(self._constructor_params):
            label.newline()
            label.add(text=" " * 15)
            label.add(text=pname, color=(255/255.0, 151/255.0, 31/255.0))
            label.add(text=" = ")
            label.add(text=pvalue, color=(153/255.0, 129/255.0, 255/255.0))

            if index < len(self._constructor_params) - 1:
                label.add(text=",")

        label.add(text=")")

        copy_text = "element = " + classname + "("

        for index, (pname, pvalue) in enumerate(self._constructor_params):
            copy_text += pname + "=" + pvalue

            if index < len(self._constructor_params) - 1:
                copy_text += ", "
        copy_text += ")"

        def copy_code(event):
            # Copies the source code to clipboard
            from Tkinter import Tk
            r = Tk()
            r.withdraw()
            r.clipboard_clear()
            r.clipboard_append(copy_text)
            r.destroy()

        self._copy_code_button.bind("click", copy_code)

        # self._source_content.fit_height_to_children()
        # self._source_container.fit_height_to_children()
        self._source_container.height += 40
예제 #4
0
class ConsoleHistoryItem:
    def __init__(self, history, text, color="font_color_entry"):
        self.history_entry = LUIFormattedLabel(
            margin=(0, 0, 0, 0),
            #padding = 10,
            #color=(0.4,0.0,0.0, 1.0),
        )
        history.add(self.history_entry)
        self.history_entry.solid = True
        self.history_entry.bind("click", self.click)

        # FIXME: Choose color based on text_type
        for text_part in text.split("\n"):
            if text_part == "":
                self.history_entry.newline()
            else:
                self.history_entry.add(text_part,
                                       font_size=15,
                                       color=colors[color])
                self.history_entry.newline()

        self.text = text
        self.original_color = color
        self.selected = False

    def click(self, lui_event):
        #print("click!")
        #print("  " + str(lui_event.name))        # click
        #print("  " + str(lui_event.sender))      # <lui.LUIObject object at 0x7f1a3eb66eb8>
        #print("  " + str(lui_event.coordinates)) # LPoint2f(58, 36)
        #print("  " + str(lui_event.message))     #
        self.selected = not self.selected
        if self.selected:
            self.history_entry.color = colors[
                "font_color_selected_history_item"]
            print(colors["font_color_selected_history_item"])
        else:
            self.history_entry.color = colors[self.original_color]
            print(colors[self.original_color])
예제 #5
0
f.construct_sourcecode("LUIFormattedLabel")

# Create a new label
label = LUIFormattedLabel(parent=f.get_widget_node())

# Add parts to the label
label.add(text="Hello ", color=(0.2,0.6,1.0))
label.add(text="World", color=(1.0,0.6,0.2))
label.add(text="! ")
label.add(text="This ", font_size=20, margin=(-6, 0, 0, 0), color=(0.4,0.2,1.0))
label.add(text="is ", color=(1.0,0.2,1.0))
label.add(text="a formatted ", font_size=10, color=(0.6,0.3,0.6))
label.add(text="Label", font_size=25, margin =(-11, 0, 0, 0), color=(0.2,1.0,0.6))

# Go to next line
label.newline()
label.newline()

# Add some more parts
label.add(text="This is the same label ..", color=(0.3,0.7,0.32))

# Go to next line
label.newline()
label.newline()

# Add some more parts
label.add(text="... but another line forced with ", color=(0.6,0.3,0.8))
label.add(text="newline() ", color=(1.0,0.6,0.2))

def make_random_color():
    return (random.random(), random.random(), random.random())
예제 #6
0
label.add(text="Hello ", color=(0.2, 0.6, 1.0))
label.add(text="World", color=(1.0, 0.6, 0.2))
label.add(text="! ")
label.add(text="This ",
          font_size=20,
          margin=(-6, 0, 0, 0),
          color=(0.4, 0.2, 1.0))
label.add(text="is ", color=(1.0, 0.2, 1.0))
label.add(text="a formatted ", font_size=10, color=(0.6, 0.3, 0.6))
label.add(text="Label",
          font_size=25,
          margin=(-11, 0, 0, 0),
          color=(0.2, 1.0, 0.6))

# Go to next line
label.newline()
label.newline()

# Add some more parts
label.add(text="This is the same label ..", color=(0.3, 0.7, 0.32))

# Go to next line
label.newline()
label.newline()

# Add some more parts
label.add(text="... but another line forced with ", color=(0.6, 0.3, 0.8))
label.add(text="newline() ", color=(1.0, 0.6, 0.2))


def make_random_color():