コード例 #1
0
ファイル: console.py プロジェクト: TheCheapestPixels/PlugBase
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
ファイル: DemoFramework.py プロジェクト: Cloudxtreme/LUI
 def add_property(self, property_name, property_type):
     label = LUIFormattedLabel()
     label.add(text=property_name,
               color=(255 / 255.0, 151 / 255.0, 31 / 255.0))
     label.add(" : ", color=(0.9, 0.9, 0.9))
     label.add(text=property_type + " ",
               color=(102 / 255.0, 217 / 255.0, 239 / 255.0))
     self._properties_layout.add(label)
     self.update_layouts()
コード例 #3
0
def send_command(event):
    """ Called when the user presses enter in the input field, submits the
    command and prints something on the console """
    label = LUIFormattedLabel()
    color = (0.9, 0.9, 0.9, 1.0)
    if event.message.startswith(u"/"):
        color = (0.35, 0.65, 0.24, 1.0)
    label.add(text=">>>  ", color=(0.35, 0.65, 0.24, 1.0))
    label.add(text=event.message, color=color)
    layout.add(label)

    result = LUIFormattedLabel()
    result.add("Your command in rot13: " + event.message.encode("rot13"), color=(0.4, 0.4, 0.4, 1.0))
    layout.add(result)
    input_field.clear()

    text_container.scroll_to_bottom()
コード例 #4
0
ファイル: DemoFramework.py プロジェクト: Tosh007/LUI
 def add_property(self, property_name, property_type):
     label = LUIFormattedLabel()
     label.add(text=property_name, color=(255/255.0, 151/255.0, 31/255.0) )
     label.add(" : ", color=(0.9,0.9,0.9) )
     label.add(text=property_type + " ", color=(102/255.0, 217/255.0, 239/255.0) )
     self._properties_layout.add(label)
     self.update_layouts()
コード例 #5
0
ファイル: console.py プロジェクト: Schwarzbaer/PlugBase
    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
コード例 #6
0
ファイル: console.py プロジェクト: Schwarzbaer/PlugBase
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])
コード例 #7
0
ファイル: console.py プロジェクト: TheCheapestPixels/PlugBase
    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
コード例 #8
0
ファイル: DemoFramework.py プロジェクト: Cloudxtreme/LUI
    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
コード例 #9
0
ファイル: DemoFramework.py プロジェクト: Cloudxtreme/LUI
    def add_public_function(self, name, parameters=None, return_type="void"):
        label = LUIFormattedLabel()
        label.add(text=return_type + " ",
                  color=(102 / 255.0, 217 / 255.0, 239 / 255.0))
        label.add(text=name + " ",
                  color=(166 / 255.0, 226 / 255.0, 46 / 255.0))

        label.add(text="( ", color=(0.9, 0.9, 0.9))

        if parameters is not None:
            for index, (pname, ptype) in enumerate(parameters):
                label.add(text=pname,
                          color=(255 / 255.0, 151 / 255.0, 31 / 255.0))
                label.add(text=" : ", color=(0.9, 0.9, 0.9))
                label.add(text=ptype,
                          color=(102 / 255.0, 217 / 255.0, 239 / 255.0))

                if index < len(parameters) - 1:
                    label.add(text=",", color=(0.9, 0.9, 0.9))
        label.add(text=" )", color=(0.9, 0.9, 0.9))
        self._functions_layout.add(label)
        self.update_layouts()
コード例 #10
0
import random

f = DemoFramework()
f.prepare_demo("LUIFormattedLabel")

# Functions
f.add_public_function("clear", [], "void")
f.add_public_function("newline", [], "void")
f.add_public_function("add", [("*args", "List"), ("**kwargs", "Dict")])

# Events
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
コード例 #11
0
ファイル: DemoFramework.py プロジェクト: cesarmarinhorj/LUI
    def construct_sourcecode(self, classname):
        self.sourceContent.remove_all_children()
        label = LUIFormattedLabel(parent=self.sourceContent)
        label.add_text(text="element ", color=(0.9,0.9,0.9))
        label.add_text(text="= ", color=(249/255.0, 38/255.0, 114/255.0))
        label.add_text(text=classname, color=(166/255.0, 226/255.0, 46/255.0))
        label.add_text(text="(", color=(0.9,0.9,0.9))

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

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

        label.add_text(text=")")

        self.sourceContent.fit_height_to_children()
        self.sourceContainer.fit_height_to_children()
        self.sourceContainer.height += 40
コード例 #12
0
ファイル: DemoFramework.py プロジェクト: cesarmarinhorj/LUI
    def add_public_function(self, name, parameters=None, return_type="void"):
        label = LUIFormattedLabel()
        label.add_text(text=return_type + " ", color = (102/255.0, 217/255.0, 239/255.0))
        label.add_text(text=name + " ", color = (166/255.0, 226/255.0, 46/255.0))

        label.add_text(text="( ", color=(0.9,0.9,0.9))

        if parameters is not None:
            for index, (pname, ptype) in enumerate(parameters):
                label.add_text(text=pname, color=(255/255.0, 151/255.0, 31/255.0))
                label.add_text(text=" : ", color=(0.9,0.9,0.9))
                label.add_text(text=ptype, color=(102/255.0, 217/255.0, 239/255.0))

                if index < len(parameters) - 1:
                    label.add_text(text=",", color=(0.9,0.9,0.9))
        label.add_text(text=" )", color=(0.9,0.9,0.9))
        self.functionsLayout.add_row(label)
        self.update_layouts()
コード例 #13
0
ファイル: DemoFramework.py プロジェクト: Tosh007/LUI
    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
コード例 #14
0
ファイル: FormattedLabel.py プロジェクト: cesarmarinhorj/LUI
f = DemoFramework()
f.prepare_demo("LUIFormattedLabel")

# Constructor


# Functions
f.add_public_function("clear", [], "void")
f.add_public_function("br", [], "void")
f.add_public_function("add_text", [("*args", "List"), ("**kwargs", "Dict")])

# Events
f.construct_sourcecode("LUIFormattedLabel")

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

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

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

# Add some more parts
コード例 #15
0
import random

f = DemoFramework()
f.prepare_demo("LUIFormattedLabel")

# Functions
f.add_public_function("clear", [], "void")
f.add_public_function("newline", [], "void")
f.add_public_function("add", [("*args", "List"), ("**kwargs", "Dict")])

# Events
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))