Example #1
0
    def test_update_depth(self):
        theme = Theme({'first depth': {
            'second depth': [0, 0, 0, 0]
        }}, 'some_path')

        update = {'first depth': {'other second depth': [1, 1, 1, 1]}}
        theme.update(update)

        # test that theme was updated
        path = ['first depth', 'other second depth']
        self.assertEqual(theme[path], [1, 1, 1, 1])
Example #2
0
    def test_update_depth(self):
        theme = Theme({'first depth': {
            'second depth': [0, 0, 0, 0]
        }}, 'some_path')

        update = {'first depth': {'other second depth': [1, 1, 1, 1]}}
        theme.update(update)

        # test that theme was updated
        path = ['first depth', 'other second depth']
        self.assertEqual(theme[path], [1, 1, 1, 1])
Example #3
0
    def test_update_with_texture(self):
        theme = Theme({'first depth': {'image': 'panel.png'}}, 'theme')

        update = {'first depth':
                      {'image':
                           {'source': 'panel.png', 'region': [0, 0, 16, 16]}
                      }
        }
        theme.update(update)

        # update is to a 16x16 image.
        self.assertEqual(theme['first depth']['image'].width, 16)
        self.assertEqual(theme['first depth']['image'].height, 16)
Example #4
0
    def setUp(self):
        self.batch = pyglet.graphics.Batch()
        self.group = pyglet.graphics.OrderedGroup(1)

        self.texture_theme = Theme({'image': 'panel.png'}, 'theme')
        self.texture_region_theme = Theme(
            {'image': {
                'source': 'panel.png',
                'region': [0, 0, 16, 16]
            }}, 'theme')
        self.frame_theme = Theme(
            {'image': {
                'source': 'panel.png',
                'frame': [8, 8, 16, 16]
            }}, 'theme')
Example #5
0
    def test_update_with_texture(self):
        theme = Theme({'first depth': {'image': 'panel.png'}}, 'theme')

        update = {
            'first depth': {
                'image': {
                    'source': 'panel.png',
                    'region': [0, 0, 16, 16]
                }
            }
        }
        theme.update(update)

        # update is to a 16x16 image.
        self.assertEqual(theme['first depth']['image'].width, 16)
        self.assertEqual(theme['first depth']['image'].height, 16)
Example #6
0
    def test_load_texture_with_dictionary(self):
        theme = Theme({'first depth': {
            'image': {
                'source': 'panel.png'
            }
        }}, 'theme')

        # panel is a 32x32 image.
        self.assertEqual(theme['first depth']['image'].width, 32)
        self.assertEqual(theme['first depth']['image'].height, 32)
Example #7
0
    def manager_settings(self):
        settings = dict(self.default_settings)

        # Load settings from default if not manually defined
        for rule, val in self.override_settings.items():
            settings[rule] = val

        settings['theme'] = Theme(self.theme(),
                                  resources_path=os.path.join(CWD, 'theme'))

        return settings
Example #8
0
    def test_access(self):
        theme = Theme({'first depth': {
            'second depth': [0, 0, 0, 0]
        }}, 'some_path')

        # test access by dict of dicts
        self.assertEqual(theme['first depth']['second depth'], [0, 0, 0, 0])

        # test access by path
        path = ['first depth', 'second depth']
        self.assertEqual(theme[path], [0, 0, 0, 0])
Example #9
0
def getPopUpMenssageTheme():
    theme = Theme(
        {
            "font": "Lucida Grande",
            "font_size": 12,
            "font_size_small": 10,
            "gui_color": [255, 255, 255, 255],
            "disabled_color": [160, 160, 160, 255],
            "text_color": [255, 255, 255, 255],
            "focus_color": [255, 255, 255, 64],
            "button": {
                "down": {
                    "focus": {
                        "image": {
                            "source": "button-highlight.png",
                            "frame": [8, 6, 2, 2],
                            "padding": [18, 18, 8, 6]
                        }
                    },
                    "image": {
                        "source": "button-down.png",
                        "frame": [6, 6, 3, 3],
                        "padding": [12, 12, 4, 2]
                    },
                    "text_color": [0, 0, 0, 255]
                },
                "up": {
                    "focus": {
                        "image": {
                            "source": "button-highlight.png",
                            "frame": [8, 6, 2, 2],
                            "padding": [18, 18, 8, 6]
                        }
                    },
                    "image": {
                        "source": "button.png",
                        "frame": [6, 6, 3, 3],
                        "padding": [12, 12, 4, 2]
                    }
                },
            },
            "frame": {
                "image": {
                    "source": "panel.png",
                    "frame": [8, 8, 16, 16],
                    "padding": [16, 16, 8, 8]
                }
            }
        },
        resources_path='theme')
    return theme
Example #10
0
    def test_load_texture_with_region(self):
        theme = Theme(
            {
                'first depth': {
                    'image': {
                        'source': 'panel.png',
                        'region': [0, 0, 16, 16]
                    }
                }
            }, 'theme')

        # region is a 16x16 image.
        self.assertEqual(theme['first depth']['image'].width, 16)
        self.assertEqual(theme['first depth']['image'].height, 16)
Example #11
0
    def test_load_frame(self):
        theme = Theme(
            {
                'first depth': {
                    'image': {
                        'source': 'panel.png',
                        'frame': [8, 8, 16, 16]
                    }
                }
            }, 'theme')

        # panel is an 32x32 image.
        self.assertEqual(theme['first depth']['image'].width, 32)
        self.assertEqual(theme['first depth']['image'].height, 32)
Example #12
0
theme = Theme(
    {
        "font": "Lucida Grande",
        "font_size": 12,
        "text_color": [255, 255, 255, 255],
        "gui_color": [255, 0, 0, 255],
        "slider": {
            "knob": {
                "image": {
                    "source": "slider-knob.png"
                },
                "offset": [-5, -11]
            },
            "padding": [8, 8, 8, 8],
            "step": {
                "image": {
                    "source": "slider-step.png"
                },
                "offset": [-2, -8]
            },
            "bar": {
                "image": {
                    "source": "slider-bar.png",
                    "frame": [8, 8, 8, 0],
                    "padding": [8, 8, 8, 8]
                }
            }
        }
    },
    resources_path='../theme/')
Example #13
0
Label = MyLabel

win = Window(640, 480, resizable=True, vsync=True)
batch = Batch()

model = Model()


@win.event
def on_draw():
    win.clear()
    batch.draw()


with open('theme/theme.json') as j:
    theme = Theme(json.load(j), resources_path='theme/')

# Set up a Manager
manager = Manager(
    VerticalContainer(
        [
            # ...
            Label(binding=Binding(context=model, path="title")),
            # ...
            VerticalContainer([
                # ...
                Label(binding=Binding(
                    template="$message", context=model, path="message")),
                # ...
                Button("Button 1", on_press=model.set_title(".")),
                OneTimeButton("Button 2", on_release=model.click),
theme = Theme(
    {
        "font": "Lucida Grande",
        "font_size": 12,
        "text_color": [255, 255, 255, 255],
        "gui_color": [255, 0, 0, 255],
        "section": {
            "right": {
                "image": {
                    "source": "line.png",
                    "region": [2, 0, 6, 4],
                    "frame": [0, 4, 4, 0],
                    "padding": [0, 0, 0, 6]
                }
            },
            "font_size": 14,
            "opened": {
                "image": {
                    "source": "book-open.png"
                }
            },
            "closed": {
                "image": {
                    "source": "book.png"
                }
            },
            "left": {
                "image": {
                    "source": "line.png",
                    "region": [0, 0, 6, 4],
                    "frame": [2, 4, 4, 0],
                    "padding": [0, 0, 0, 6]
                }
            },
            "center": {
                "image": {
                    "source": "line.png",
                    "region": [2, 0, 4, 4],
                    "frame": [0, 4, 4, 0],
                    "padding": [0, 0, 0, 6]
                }
            }
        },
        "frame": {
            "image": {
                "source": "panel.png",
                "frame": [8, 8, 16, 16],
                "padding": [16, 16, 8, 8]
            }
        }
    },
    resources_path='../theme/')
Example #15
0
theme = Theme(
    {
        "font": defaultFont.name,
        "font_size": 16,
        "font_size_small": 10,
        "gui_color": [255, 255, 255, 255],
        "disabled_color": [160, 160, 160, 255],
        "text_color": [220, 220, 220, 255],
        "focus_color": [255, 255, 255, 64],
        "highlight_color": [255, 255, 255, 255],
        "button": {
            "down": {
                "highlight": {
                    "image": {
                        "source": "button_down.png",
                        "frame": [6, 6, 6, 6],
                        "padding": [5, 5, 3, 3]
                    },
                    "gui_color": [255, 255, 255, 255],
                    "text_color": loginFontColor
                },
                "image": {
                    "source": "button_press.png",
                    "frame": [6, 6, 6, 6],
                    "padding": [5, 5, 3, 3]
                },
                "gui_color": [255, 255, 255, 255],
                "text_color": loginFontColor
            },
            "up": {
                "highlight": {
                    "image": {
                        "source": "button_down.png",
                        "frame": [6, 6, 6, 6],
                        "padding": [5, 5, 3, 3]
                    },
                    "gui_color": [255, 255, 255, 255],
                    "text_color": loginFontColor
                },
                "image": {
                    "source": "button_up.png",
                    "frame": [6, 6, 6, 6],
                    "padding": [5, 5, 3, 3]
                },
                "gui_color": [255, 255, 255, 255],
                "text_color": loginFontColor
            },
            "font_size": 13
        },
        "frame": {
            "image": {
                "source": "dialog_alternative_2.png",
                "frame": [13, 13, 10, 10],  #12,10,9,8
                "padding": [15, 15, 12, 10]
            },
            "gui_color": [255, 255, 255, 255],
        },
        "frame_npc_talk_shop": {
            "image": {
                "source": "dialog_npc_talk_shop.png",  #dialogtest2
                "frame": [13, 13, 10, 10],  #12,10,9,8
                "padding": [15, 15, 12, 10]
            },
            "gui_color": [255, 255, 255, 255],
        },
        "frame_npc_talk": {
            "image": {
                "source": "dialog_npc_talk.png",  #dialogtest2
                "frame": [13, 13, 10, 10],  #12,10,9,8
                "padding": [15, 15, 12, 10]
            },
            "gui_color": [255, 255, 255, 255],
        },
        "frame_alternative": {
            "image": {
                "source": "dialog_alternative_1.png",
                "frame": [7, 7, 7, 7],  #12,10,9,8
                "padding": [8, 8, 5, 5]
            },
            "gui_color": [255, 255, 255, 255],
        },
        "input": {
            "image": {
                "source": "input_alternative.png",
                "frame": [5, 5, 5, 5],
                "padding": [3, 3, 2, 3]
            },
            "focus_color": [0, 0, 0, 0],
            "focus": {
                "image": {
                    "source": "input_alternative.png"
                }
            },
            "gui_color": [255, 255, 255, 255],
        },
        "dropdown": {
            "pulldown": {
                "image": {
                    "source": "dialog_alternative_1.png",
                    "frame": [7, 7, 7, 7],
                    "padding": [8, 8, 5, 5]
                },
                "gui_color": [255, 255, 255, 220],
                "font_size": 12
            },
            "image": {
                "source": "button_up.png",
                "frame": [6, 6, 6, 6],
                "padding": [6, 6, 6, 6]
            },
            "highlight": {
                "image": {
                    "source": "button_down.png",
                    "frame": [6, 6, 6, 6],
                    "padding": [0, 0, 0, 0]
                },
                "gui_color": [255, 255, 255, 255],
                "text_color": loginFontColor
            },
            "text_color": loginFontColor,
            "font_size": 12
        },
        "vscrollbar": {
            "knob": {
                "image": {
                    "source": "vscrollbar.png",
                    "region": [0, 16, 16, 16],
                    "frame": [0, 6, 16, 4],
                    "padding": [0, 0, 0, 0]
                },
                "offset": [0, 0]
            },
            "bar": {
                "image": {
                    "source": "vscrollbar.png",
                    "region": [0, 64, 16, 16]
                },
                "padding": [0, 0, 0, 0]
            }
        },
        "checkbox": {
            "checked": {
                "image": {
                    "source": "checkbox_checked.png",
                    "frame": [4, 4, 4, 4]
                }
            },
            "unchecked": {
                "image": {
                    "source": "checkbox.png",
                    "frame": [4, 4, 4, 4]
                }
            }
        },
        'chatwhisper': {
            "down": {
                "highlight": {
                    "image": {
                        "source": "chatwhisperhighlighted.png"
                    }
                },
                "image": {
                    "source": "chatwhisperhighlighted.png"
                }
            },
            "up": {
                "highlight": {
                    "image": {
                        "source": "chatwhisperhighlighted.png"
                    }
                },
                "image": {
                    "source": "chatwhisper.png"
                }
            },
            "gui_color": [255, 255, 255, 255]
        },
        'delete_alt': {
            'down': {
                "highlight": {
                    "image": {
                        "source": "deletehighlighted.png"
                    }
                },
                "image": {
                    "source": "deletehighlighted.png"
                }
            },
            'up': {
                "highlight": {
                    "image": {
                        "source": "deletehighlighted.png"
                    }
                },
                "image": {
                    "source": "delete.png"
                }
            }
        },
        'delete': {
            'down': {
                "highlight": {
                    "image": {
                        "source": "closebuttondown.png"
                    }
                },
                "image": {
                    "source": "closebuttonpress.png"
                }
            },
            'up': {
                "highlight": {
                    "image": {
                        "source": "closebuttondown.png"
                    }
                },
                "image": {
                    "source": "closebuttonup.png"
                }
            },
            "gui_color": [255, 255, 255, 255],
            "text_color": loginFontColor
        },
        "btn_friendwindow": {
            "down": {
                "highlight": {
                    "image": {
                        "source": "friendshighlighted.png"
                    }
                },
                "image": {
                    "source": "friendshighlighted.png"
                }
            },
            "up": {
                "highlight": {
                    "image": {
                        "source": "friendshighlighted.png"
                    }
                },
                "image": {
                    "source": "friends.png"
                }
            }
        },
        "mail": {
            "down": {
                "highlight": {
                    "image": {
                        "source": "mailhighlighted.png"
                    }
                },
                "image": {
                    "source": "mailhighlighted.png"
                }
            },
            "up": {
                "highlight": {
                    "image": {
                        "source": "mailhighlighted.png"
                    }
                },
                "image": {
                    "source": "mail.png"
                }
            }
        },
        "mailopen": {
            "down": {
                "highlight": {
                    "image": {
                        "source": "mailopenhighlighted1.png"
                    }
                },
                "image": {
                    "source": "mailopenhighlighted1.png"
                }
            },
            "up": {
                "highlight": {
                    "image": {
                        "source": "mailopenhighlighted1.png"
                    }
                },
                "image": {
                    "source": "mailopen1.png"
                }
            }
        },
        "guild": {
            "down": {
                "highlight": {
                    "image": {
                        "source": "guildhighlighted.png"
                    }
                },
                "image": {
                    "source": "guildhighlighted.png"
                }
            },
            "up": {
                "highlight": {
                    "image": {
                        "source": "guildhighlighted.png"
                    }
                },
                "image": {
                    "source": "guild.png"
                }
            }
        },
        "close": {
            "down": {
                "highlight": {
                    "image": {
                        "source": "closebuttondown.png"
                    }
                },
                "image": {
                    "source": "closebuttonpress.png"
                }
            },
            "up": {
                "highlight": {
                    "image": {
                        "source": "closebuttondown.png"
                    }
                },
                "image": {
                    "source": "closebuttonpress.png"
                }
            },
            "gui_color": [255, 255, 255, 255]
        },
        "es": {
            "down": {
                "highlight": {
                    "image": {
                        "source": "goldeneshighlighted.png"
                    }
                },
                "image": {
                    "source": "goldeneshighlighted.png"
                }
            },
            "up": {
                "highlight": {
                    "image": {
                        "source": "goldeneshighlighted.png"
                    }
                },
                "image": {
                    "source": "goldenes.png"
                }
            },
            "gui_color": [255, 255, 255, 255]
        },
        "menes": {
            "down": {
                "highlight": {
                    "image": {
                        "source": "menes.png"
                    }
                },
                "image": {
                    "source": "menes.png"
                }
            },
            "up": {
                "highlight": {
                    "image": {
                        "source": "menes.png"
                    }
                },
                "image": {
                    "source": "meneshighlighted.png"
                }
            },
            "gui_color": [255, 255, 255, 255]
        },
        "btn_ignorewindow": {
            "down": {
                "highlight": {
                    "image": {
                        "source": "ignoreshighlighted.png"
                    }
                },
                "image": {
                    "source": "ignoreshighlighted.png"
                }
            },
            "up": {
                "highlight": {
                    "image": {
                        "source": "ignoreshighlighted.png"
                    }
                },
                "image": {
                    "source": "ignores.png"
                }
            },
            "gui_color": [255, 255, 255, 255]
        },
        "bag": {
            "image": {
                "source": "bag.png"
            }
        },
        "baghighlighted": {
            "image": {
                "source": "baghighlighted.png"
            }
        },
        "es_icon": {
            "image": {
                "source": "es.png"
            }
        },
        "euro": {
            "image": {
                "source": "euro.png"
            }
        },
        "ping_green": {
            "image": {
                "source": "ping_green.png"
            }
        },
        "ping_red": {
            "image": {
                "source": "ping_red.png"
            }
        },
        "ping_yellow": {
            "image": {
                "source": "ping_yellow.png"
            }
        },
        "document": {
            "image": {
                "source": "chatboxbg.png"
            },
            "gui_color": [255, 255, 255, 255]
        },
        "settings": {
            "down": {
                "highlight": {
                    "image": {
                        "source": "settingshighlighted.png"
                    }
                },
                "image": {
                    "source": "settingshighlighted.png"
                }
            },
            "up": {
                "highlight": {
                    "image": {
                        "source": "settingshighlighted.png"
                    }
                },
                "image": {
                    "source": "settings.png"
                }
            },
            "gui_color": [255, 255, 255, 255]
        },
        'empty': {
            "down": {
                "image": {
                    "source": 'emptypixel.png'
                }
            },
            "up": {
                "image": {
                    "source": 'emptypixel.png'
                }
            },
            "gui_color": [255, 255, 255, 255]
        },
        'partyleader': {
            "image": {
                "source": 'partyleader.png'
            }
        },
        'partymember': {
            "image": {
                "source": 'meneoutline.png'
            }
        },
        'menewindowbutton': {
            "down": {
                "image": {
                    "source": 'meneoutline_selected.png',
                    "frame": [11, 11, 11, 11]
                }
            },
            "up": {
                "image": {
                    "source": 'meneoutline.png',
                    "frame": [11, 11, 11, 11]
                }
            }
        },
        'abilityoutline': {
            "image": {
                "source": 'ability_outline.png',
                "frame": [9, 9, 9, 9]
            }
        },
        'abilityoutline_disabled': {
            "image": {
                "source": 'ability_outline_disabled.png',
                "frame": [9, 9, 9, 9]
            }
        },
        'abilityoutline_highlighted': {
            "image": {
                "source": 'ability_outline_highlighted.png',
                "frame": [9, 9, 9, 9]
            }
        },
        'baroutline': {
            'image': {
                'source': 'bar_outline.png',
                "frame": [4, 4, 4, 4]
            }
        },
        'leavematch': {
            'image': {
                'source': 'leavematch.png'
            }
        },
        'mymenes': {
            'image': {
                'source': 'mymenes.png'
            }
        },
        'empty': {
            "down": {
                "highlight": {
                    "image": {
                        'source': 'emptyhighlighted.png',
                        "frame": [4, 4, 4, 4]
                    }
                },
                "image": {
                    'source': 'emptyhighlighted.png',
                    "frame": [4, 4, 4, 4]
                }
            },
            "up": {
                "highlight": {
                    "image": {
                        'source': 'emptyhighlighted.png',
                        "frame": [4, 4, 4, 4]
                    }
                },
                "image": {
                    'source': 'empty.png',
                    "frame": [4, 4, 4, 4]
                }
            }
        },
        'baroutline_btn': {
            "down": {
                "highlight": {
                    "image": {
                        'source': 'emptyhighlighted1.png',
                        "frame": [4, 4, 4, 4]
                    }
                },
                "image": {
                    'source': 'emptyhighlighted1.png',
                    "frame": [4, 4, 4, 4]
                }
            },
            "up": {
                "highlight": {
                    "image": {
                        'source': 'emptyhighlighted1.png',
                        "frame": [4, 4, 4, 4]
                    }
                },
                "image": {
                    'source': 'empty1.png',
                    "frame": [1, 1, 1, 1]
                }
            },
            "text_color": loginFontColor
        },
        'hpbar': {
            'image': {
                'source': 'hpbar.png'
            }
        },
        'xpbar': {
            'image': {
                'source': 'xpbar.png'
            }
        },
        "slider": {
            "knob": {
                "image": {
                    "source": "slider_knob.png"
                },
                "offset": [-4, -10]
            },
            "padding": [8, 8, 8, 8],
            "step": {
                "image": {
                    "source": "slider-step.png"
                },
                "offset": [-2, -8]
            },
            "bar": {
                "image": {
                    "source": "slider_bg.png",
                    "frame": [4, 4, 4, 4],
                    "padding": [8, 8, 8, 8]
                }
            }
        }
    },
    resources_path=dataPath + '/theme/')
Example #16
0
theme = Theme({"font": "Lucida Grande",
			   "font_size": 12,
			   "text_color": [255, 255, 255, 255],
			   "gui_color": [255, 0, 0, 255],
			   "input": {
				#	"text" : letters,
				   "image": {
					   "source": "input.png",
					   "frame": [3, 3, 2, 2],
					   "padding": [3, 3, 2, 3]
				   },
				   # need a focus color
				   "focus_color": [255, 255, 255, 64],
				   "focus": {
					   "image": {
						   "source": "input-highlight.png"
					   } }},
				"slider": {
                   "knob": {
                       "image": {
                           "source": "slider-knob.png"
                       },
                       "offset": [-5, -11]
                   },
                   "padding": [8, 8, 8, 8],
                   "step": {
                       "image": {
                           "source": "slider-step.png"
                       },
                       "offset": [-2, -8]
                   },
                   "bar": {
                       "image": {
                           "source": "slider-bar.png",
                           "frame": [8, 8, 8, 0],
                           "padding": [8, 8, 8, 8]
                       }
                   }
               },
			  }, resources_path='theme/')
Example #17
0
    def __init__(self, *, window, **kwargs):
        self.vertex_list = None
        batch = pyglet.graphics.Batch()
        controller.window = window
        controller.manager = self

        with open('theme/theme.json') as f:
            theme = Theme(load(f), resources_path='./theme')

        super().__init__(VerticalContainer([
            Frame(
                Wrapper(
                    VerticalContainer([
                        SectionHeader("Map Tablet to MIDI outputs"),
                        HorizontalContainer([
                            Label("Controller tablet"),
                            binding_devices.bind(
                                Dropdown(controller.tablet_names), 'tablet'),
                        ]),
                        HorizontalContainer([
                            Label("Map pointer"),
                            bind_tablet_key.bind(
                                Dropdown(controller.tablet_cursor_names),
                                'cursor'),
                            Label("with"),
                            Label("active button"),
                            bind_tablet_key.bind(
                                Dropdown(controller.tablet_button_names),
                                'button'),
                            Label("as:")
                        ]),
                        GridContainer([
                            [
                                bind_tablet_x.bind(Button("X"), 'enabled'),
                                Label("to channel"),
                                bind_tablet_x.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_tablet_x.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_tablet_x.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_tablet_x.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_tablet_x.bind(TextInput(), 'range_from'),
                                Label("to"),
                                bind_tablet_x.bind(TextInput(), 'range_to'),
                                Label("threshold"),
                                bind_tablet_x.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=100.0,
                                                     steps=20), 'threshold'),
                            ],
                            [
                                bind_tablet_y.bind(Button("Y"), 'enabled'),
                                Label("to channel"),
                                bind_tablet_y.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_tablet_y.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_tablet_y.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_tablet_y.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_tablet_y.bind(TextInput(), 'range_from'),
                                Label("to"),
                                bind_tablet_y.bind(TextInput(), 'range_to'),
                                Label("threshold"),
                                bind_tablet_y.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=100.0,
                                                     steps=20), 'threshold'),
                            ],
                            [
                                bind_tablet_p.bind(Button("Pressure"),
                                                   'enabled'),
                                Label("to channel"),
                                bind_tablet_p.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_tablet_p.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_tablet_p.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_tablet_p.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_tablet_p.bind(TextInput(), 'range_from'),
                                Label("to"),
                                bind_tablet_p.bind(TextInput(), 'range_to'),
                                Label("threshold"),
                                bind_tablet_p.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=1.0,
                                                     steps=20), 'threshold'),
                            ],
                        ]),
                    ]))),
            Frame(
                Wrapper(
                    VerticalContainer([
                        SectionHeader("Map Mouse to MIDI outputs"),
                        HorizontalContainer([
                            Label("Map mouse with active button"),
                            bind_mouse_key.bind(
                                Dropdown(controller.mouse_button_names),
                                'button'),
                            Label("as:"),
                        ]),
                        GridContainer([
                            [
                                bind_mouse_x.bind(Button("X"), 'enabled'),
                                Label("to channel"),
                                bind_mouse_x.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_mouse_x.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_mouse_x.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_mouse_x.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_mouse_x.bind(TextInput(), 'range_from'),
                                Label("to"),
                                bind_mouse_x.bind(TextInput(), 'range_to'),
                                Label("threshold"),
                                bind_mouse_x.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=100.0,
                                                     steps=20), 'threshold'),
                            ],
                            [
                                bind_mouse_y.bind(Button("Y"), 'enabled'),
                                Label("to channel"),
                                bind_mouse_y.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_mouse_y.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_mouse_y.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_mouse_y.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_mouse_y.bind(TextInput(), 'range_from'),
                                Label("to"),
                                bind_mouse_y.bind(TextInput(), 'range_to'),
                                Label("threshold"),
                                bind_mouse_y.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=100.0,
                                                     steps=20), 'threshold'),
                            ],
                        ]),
                        HorizontalContainer([
                            Label("Map mouse wheel as:"),
                        ]),
                        GridContainer([
                            [
                                bind_mouse_wheel_x.bind(
                                    Button("X"), 'enabled'),
                                Label("to channel"),
                                bind_mouse_wheel_x.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_mouse_wheel_x.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_mouse_wheel_x.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_mouse_wheel_x.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_mouse_wheel_x.bind(
                                    TextInput(), 'range_from'),
                                Label("to"),
                                bind_mouse_wheel_x.bind(
                                    TextInput(), 'range_to'),
                                Label("step"),
                                bind_mouse_wheel_x.bind(TextInput(), 'step'),
                                Label("value"),
                                bind_mouse_wheel_x.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=100.0,
                                                     steps=20), 'value'),
                                bind_mouse_wheel_x.bind(
                                    Checkbox('pull back'), 'pull_back'),
                            ],
                            [
                                bind_mouse_wheel_y.bind(
                                    Button("Y"), 'enabled'),
                                Label("to channel"),
                                bind_mouse_wheel_y.bind(
                                    Dropdown(controller.midi_channels),
                                    'channel'),
                                Label("as"),
                                HorizontalContainer([
                                    bind_mouse_wheel_y.bind(
                                        Dropdown(
                                            controller.midi_message_types),
                                        'message_type'),
                                    bind_mouse_wheel_y.widget(
                                        HorizontalContainer([
                                            Label("for"),
                                            bind_mouse_wheel_y.bind(
                                                Dropdown(controller.
                                                         midi_control_types),
                                                'control_type'),
                                        ],
                                                            hidden=True),
                                        'control_group'),
                                ]),
                                Label("ranging from"),
                                bind_mouse_wheel_y.bind(
                                    TextInput(), 'range_from'),
                                Label("to"),
                                bind_mouse_wheel_y.bind(
                                    TextInput(), 'range_to'),
                                Label("step"),
                                bind_mouse_wheel_y.bind(TextInput(), 'step'),
                                Label("value"),
                                bind_mouse_wheel_y.bind(
                                    HorizontalSlider(min_value=0.0,
                                                     max_value=100.0,
                                                     steps=20), 'value'),
                                bind_mouse_wheel_y.bind(
                                    Checkbox('pull back'), 'pull_back'),
                            ],
                        ]),
                    ]))),
            HorizontalContainer([
                binding_buttons.bind(Button(label="Tablet Input On"),
                                     'tablet_on'),
                binding_buttons.bind(Button(label="Mouse Input On"),
                                     'mouse_on'),
                Button(label="Fullscreen",
                       on_press=controller.toggle_fullscreen),
                OneTimeButton('All Notes Off',
                              on_release=controller.midi_all_notes_off),
                OneTimeButton('Hide', on_release=controller.toggle_gui)
            ]),
            Frame(
                Wrapper(
                    VerticalContainer([
                        SectionHeader("Output Device"),
                        GridContainer([
                            [
                                Label("Output MIDI port"),
                                binding_devices.bind(
                                    Dropdown(controller.midi_ports),
                                    'output_midi_port_name'),
                            ],
                        ]),
                        HorizontalContainer([
                            binding_buttons.bind(
                                Button(label="MIDI Output On"),
                                'midi_output_on'),
                            binding_buttons.bind(Button(label="Log Output"),
                                                 'log_output_on'),
                            binding_buttons.bind(Button(label="Log Input"),
                                                 'log_input_on'),
                        ]),
                    ]))),
            Frame(
                Wrapper(
                    VerticalContainer([
                        SectionHeader("Status"),
                        Label("Input:", bold=True),
                        binding_labels.bind(Label("---"), 'touch_status'),
                        binding_labels.bind(Label("---"), 'mouse_status'),
                        Label("Output:", bold=True),
                        binding_labels.bind(Label("---"), 'output_status'),
                    ]))),
        ]),
                         theme=theme,
                         window=window,
                         batch=batch,
                         **kwargs)

        controller.start_listen_bindings()
        controller.update_widgets()

        @window.event
        def on_resize(width, height):
            controller.clear_scale_cache()
            controller.note_labels.clear()
            controller.calculate_grid()

        # if __debug__:
        #     fps_display = pyglet.clock.ClockDisplay()

        @window.event
        def on_draw():
            window.clear()

            if self.vertex_list:
                self.vertex_list.draw(pyglet.gl.GL_QUADS)

            if controller.gui_visible:
                batch.draw()

            for label in controller.note_labels:
                label.draw()

            # if __debug__:
            #     fps_display.draw()

        @window.event
        def on_text(text):
            controller.on_keyboard_input(text)
Example #18
0
from setup import *

from pyglet_gui.manager import Manager
from pyglet_gui.gui import Frame, Label
from pyglet_gui.theme import Theme

theme = Theme(
    {
        "font": "Lucida Grande",
        "font_size": 12,
        "text_color": [255, 255, 255, 255],
        "gui_color": [255, 0, 0, 255],
        "frame": {
            "image": {
                "source": "panel.png",
                "frame": [8, 8, 16, 16],
                "padding": [8, 8, 0, 0]
            }
        }
    },
    resources_path='../theme/')

Manager(Frame(Label('An example of a white label with a red frame')),
        window=window,
        batch=batch,
        theme=theme)

pyglet.app.run()
Example #19
0
theme = Theme(
    {
        "font": "Lucida Grande",
        "font_size": 12,
        "text_color": [255, 255, 255, 255],
        "gui_color": [255, 0, 0, 255],
        "button": {
            "down": {
                "image": {
                    "source": "button-down.png",
                    "frame": [8, 6, 2, 2],
                    "padding": [18, 18, 8, 6]
                },
                "text_color": [0, 0, 0, 255]
            },
            "up": {
                "image": {
                    "source": "button.png",
                    "frame": [6, 5, 6, 3],
                    "padding": [18, 18, 8, 6]
                }
            }
        },
        "vscrollbar": {
            "knob": {
                "image": {
                    "source": "vscrollbar.png",
                    "region": [0, 16, 16, 16],
                    "frame": [0, 6, 16, 4],
                    "padding": [0, 0, 0, 0]
                },
                "offset": [0, 0]
            },
            "bar": {
                "image": {
                    "source": "vscrollbar.png",
                    "region": [0, 64, 16, 16]
                },
                "padding": [0, 0, 0, 0]
            }
        }
    },
    resources_path='../theme/')
from pyglet_gui.containers import VerticalContainer, HorizontalContainer, GridContainer
from pyglet_gui.theme import Theme

theme = Theme(
    {
        "font": "Lucida Grande",
        "font_size": 12,
        "text_color": [255, 255, 255, 255],
        "gui_color": [255, 0, 0, 255],
        "button": {
            "down": {
                "image": {
                    "source": "button-down.png",
                    "frame": [8, 6, 2, 2],
                    "padding": [18, 18, 8, 6]
                },
                "text_color": [0, 0, 0, 255]
            },
            "up": {
                "image": {
                    "source": "button.png",
                    "frame": [6, 5, 6, 3],
                    "padding": [18, 18, 8, 6]
                }
            }
        }
    },
    resources_path='../theme/')

hlay = HorizontalContainer(content=[
    VerticalContainer(
theme = Theme(
    {
        "font": "Lucida Grande",
        "font_size": 12,
        "font_size_small": 10,
        "gui_color": [255, 255, 255, 255],
        "disabled_color": [160, 160, 160, 255],
        "text_color": [255, 255, 255, 255],
        "highlight_color": [255, 255, 255, 64],
        "button": {
            "down": {
                "highlight": {
                    "image": {
                        "source": "button-highlight.png",
                        "frame": [8, 6, 2, 2],
                        "padding": [18, 18, 8, 6]
                    }
                },
                "image": {
                    "source": "button-down.png",
                    "frame": [6, 6, 3, 3],
                    "padding": [12, 12, 4, 2]
                },
                "text_color": [0, 0, 0, 255]
            },
            "up": {
                "highlight": {
                    "image": {
                        "source": "button-highlight.png",
                        "frame": [8, 6, 2, 2],
                        "padding": [18, 18, 8, 6]
                    }
                },
                "image": {
                    "source": "button.png",
                    "frame": [6, 6, 3, 3],
                    "padding": [12, 12, 4, 2]
                }
            }
        }
    },
    resources_path='../theme/')
Example #22
0
from pyglet_gui.mixins import HighlightMixin
from pyglet_gui.manager import Manager
from pyglet_gui.buttons import Button, OneTimeButton, Checkbox, GroupButton
from pyglet_gui.scrollable import Scrollable
from pyglet_gui.document import Document
from pyglet_gui.constants import ANCHOR_CENTER, HALIGN_LEFT, HALIGN_RIGHT, ANCHOR_RIGHT, ANCHOR_TOP_LEFT, ANCHOR_BOTTOM_LEFT, ANCHOR_BOTTOM_RIGHT, ANCHOR_TOP, ANCHOR_TOP_RIGHT
from pyglet_gui.gui import Label, Graphic, Frame, PopupConfirm
from pyglet_gui.text_input import TextInput
from pyglet_gui.theme import Theme
from pyglet_gui.containers import VerticalContainer, HorizontalContainer, Spacer, GridContainer

import copy
import os
import json

UI_THEME = Theme(json.load(open('client_data/theme/mmo_theme.json', 'r')),
                 resources_path='client_data/theme/')


class ConnectManager(Manager):
    def __init__(self, client):

        self.client = client

        self.connect_button = OneTimeButton(label="Connect",
                                            on_release=self.connect)
        self.server_field = TextInput("localhost")
        self.port_field = TextInput("10000")
        self.connect_container = VerticalContainer(
            [self.connect_button, self.server_field, self.port_field])
        Manager.__init__(self,
                         Frame(self.connect_container, path='connectFrame'),
Example #23
0
from pyglet_gui.document import Document
from pyglet_gui.theme import Theme

theme = Theme(
    {
        "font": "Lucida Grande",
        "font_size": 12,
        "text_color": [255, 255, 255, 255],
        "gui_color": [64, 64, 64, 255],
        "vscrollbar": {
            "knob": {
                "image": {
                    "source": "vscrollbar.png",
                    "region": [0, 16, 16, 16],
                    "frame": [0, 6, 16, 4],
                    "padding": [0, 0, 0, 0]
                },
                "offset": [0, 0]
            },
            "bar": {
                "image": {
                    "source": "vscrollbar.png",
                    "region": [0, 64, 16, 16]
                },
                "padding": [0, 0, 0, 0]
            }
        }
    },
    resources_path='../theme')

document = pyglet.text.decode_attributed('''
In {bold True}Pyglet-gui{bold False} you can use
Example #24
0
def getTheme():
    theme = Theme(
        {
            "font": "Lucida Grande",
            "font_size": 16,
            "text_color": [255, 255, 255, 255],
            "gui_color": [255, 255, 255, 255],
            "button": {
                "down": {
                    "image": {
                        "source": "button-down.png",
                        "frame": [6, 6, 3, 3],
                        "padding": [12, 12, 4, 2]
                    },
                    "text_color": [0, 0, 0, 255]
                },
                "up": {
                    "image": {
                        "source": "button.png",
                        "frame": [6, 6, 3, 3],
                        "padding": [12, 12, 4, 2]
                    }
                }
            },
            "frame": {
                "image": {
                    "source": "panel.png",
                    "frame": [8, 8, 16, 16],
                    "padding": [8, 8, 0, 0]
                }
            },
            "vscrollbar": {
                "knob": {
                    "image": {
                        "source": "vscrollbar.png",
                        "region": [0, 16, 16, 16],
                        "frame": [0, 6, 16, 4],
                        "padding": [0, 0, 0, 0]
                    },
                    "offset": [0, 0]
                },
                "bar": {
                    "image": {
                        "source": "vscrollbar.png",
                        "region": [0, 64, 16, 16]
                    },
                    "padding": [0, 0, 0, 0]
                }
            },
            "checkbox": {
                "checked": {
                    "image": {
                        "source": "checkbox-checked.png"
                    }
                },
                "unchecked": {
                    "image": {
                        "source": "checkbox.png"
                    }
                }
            },
        },
        resources_path='theme')
    return theme
Example #25
0
import sys
import hashlib
from pyglet_gui.containers import VerticalContainer
from pyglet.gl import *
from twisted.internet import reactor, error
from twisted.internet.task import LoopingCall
from twisted.internet.protocol import Protocol, Factory, ClientFactory
from twisted.protocols.basic import LineReceiver
from pyglet_gui.manager import Manager
from pyglet_gui.gui import Frame, Spacer, Label
from pyglet_gui.theme import Theme

theme = Theme(
    {
        "font": "Segoe UI",
        "font_size": 26,
        "text_color": (255, 255, 255, 255)
    },
    resources_path=None)
ServerPackets = {
    "SendHashes": 1,
    "SendFileInfo": 2,
    "DownloadFinished": 3,
    "DownloadSize": 4
}
ClientPackets = {"SendHashes": 1, "Received": 2, "Validating": 3}
MODE_INIT = 0
MODE_CONNECTING = 1
MODE_CONNECTED = 2
MODE_DISCONNECTED = 3
MODE_CONNECTIONFAILED = 4
from pyglet_gui.manager import Manager
from pyglet_gui.text_input import TextInput
from pyglet_gui.theme import Theme

theme = Theme(
    {
        "font": "Lucida Grande",
        "font_size": 12,
        "text_color": [255, 255, 255, 255],
        "gui_color": [255, 0, 0, 255],
        "input": {
            "image": {
                "source": "input.png",
                "frame": [3, 3, 2, 2],
                "padding": [3, 3, 2, 3]
            },
            # need a focus color
            "focus_color": [255, 255, 255, 64],
            "focus": {
                "image": {
                    "source": "input-highlight.png"
                }
            }
        }
    },
    resources_path='../theme/')

# Set up a Manager
Manager(TextInput(text="Write on me"), window=window, batch=batch, theme=theme)

pyglet.app.run()
Example #27
0
theme = Theme(
    {
        "font": "Lucida Grande",
        "font_size": 12,
        "text_color": [255, 255, 255, 255],
        "gui_color": [255, 255, 255, 255],
        "button": {
            "down": {
                "image": {
                    "source": "button-down.png",
                    "frame": [6, 6, 3, 3],
                    "padding": [12, 12, 4, 2]
                },
                "text_color": [0, 0, 0, 255]
            },
            "up": {
                "image": {
                    "source": "button.png",
                    "frame": [6, 6, 3, 3],
                    "padding": [12, 12, 4, 2]
                }
            }
        },
        "checkbox": {
            "checked": {
                "image": {
                    "source": "checkbox-checked.png"
                }
            },
            "unchecked": {
                "image": {
                    "source": "checkbox.png"
                }
            }
        }
    },
    resources_path='../theme/')