Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible method of making Compound Controls #84

Closed
wants to merge 4 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions mGui/core/compound.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

import weakref

from .controls import IntField, IconTextButton, Button
from ..forms import HorizontalStretchForm, VerticalStretchForm
from ..events import MayaEvent

class IntSpinner(IntField):

def __init__(self, key=None, **kwargs):
self._step = kwargs.pop('step', 1)
height = kwargs.pop('height', kwargs.pop('h', 32))
width = kwargs.pop('width', kwargs.pop('w', 256))
with HorizontalStretchForm(key='IntSpinner#', height=height, width=width) as self._root:
super(IntSpinner, self).__init__(key, height=height, width=width - height, **kwargs)
with VerticalStretchForm():
self._up = Button(height=height / 2, width=height, label='^') #, style='iconOnly') #, image='caret-top')
self._down = Button(height=height / 2, width=height, label='v') #, style='iconOnly') #, image='caret-bottom')

self._up.command += self._inc
self._down.command += self._dec
print(self.height, self.width)


@property
def step(self):
return self._step

@step.setter
def step(self, value):
self._step = value

def _inc(self, *args, **kwargs):
self.value += self._step

def _dec(self, *args, **kwargs):
self.value -= self._step