def __init__(self, parent): AbsolutePanel.__init__(self) self.roleList = ListBox() self.roleList.setWidth('300px') self.roleList.setVisibleItemCount(6) self.roleList.addChangeListener(self.onListChange) #self.roleList.addKeyboardListener(self) self.roleCombo = ListBox() self.roleCombo.addKeyboardListener(self) self.roleCombo.addChangeListener(self.onComboChange) self.addBtn = Button("Add") self.addBtn.setEnabled(False) self.removeBtn = Button("Remove") self.removeBtn.setEnabled(False) vpanel = VerticalPanel() vpanel.add(self.roleList) hpanel = HorizontalPanel() hpanel.add(self.roleCombo) hpanel.add(self.addBtn) hpanel.add(self.removeBtn) vpanel.add(hpanel) self.add(vpanel) self.clearForm() return
def __init__(self): AbsolutePanel.__init__(self) self.app = CompaniesApp() self.history = [] self.save = Button("save", self) self.selectDepartment = Button("select", self) self.selectEmployee = Button("select", self) self.edit = Button("edit", self) self.cut = Button("cut", self) self.back = Button("back", self) self.name = TextBox() self.address = TextBox() self.manager = TextBox() self.departments = ListBox(Size=("100%"), VisibleItemCount="5") self.employees = ListBox(Size=("100%"), VisibleItemCount="5") self.total = TextBox() self.errors = VerticalPanel() self.grid = Grid() self.allPanels = VerticalPanel() self.allPanels.add(self.grid) self.allPanels.add(self.errors) self.add(self.allPanels) self.initCompanyGUI()
def __init__(self): AbsolutePanel.__init__(self) StyleSheetCssText(margins) # initialize css... header = """<div><H2 align="center">Welcome to Unbeatable Tic-Tac-Toe!</H2><br>My <a href="https://github.com/chetweger/min-max-games/blob/master/ttt/ttt.py">implementation</a> uses the min-max search algorithm with alpha beta pruning and a transposition table!</div>""" header = HTML(header, StyleName='margins_both') self.add(header) self.ai_first = Button("AI first.", self, StyleName='margins_left') self.add(self.ai_first) self.new_game = Button("New game", self, StyleName='margins_left') self.add(self.new_game) self.g=Grid(StyleName='margins_left') self.g.resize(3, 3) self.g.setBorderWidth(2) self.g.setCellPadding(4) self.g.setCellSpacing(1) self.init() self.add(self.g) self.state = State() self.game_resolution=Label("", StyleName='margins_left') self.add(self.game_resolution)
def __init__(self, parent): AbsolutePanel.__init__(self) self.userGrid = Grid() self.userGrid.createGrid(6, 6) self.userGrid.addTableListener(self) self.userGrid.setBorderWidth(2) self.userGrid.setCellPadding(4) self.userGrid.setCellSpacing(1) self.userGrid.setColLabelValue(0, "Username") self.userGrid.setColLabelValue(1, "First Name") self.userGrid.setColLabelValue(2, "Last Name") self.userGrid.setColLabelValue(3, "Email") self.userGrid.setColLabelValue(4, "Department") self.userGrid.setColLabelValue(5, "Password") self.newBtn = Button("New") self.deleteBtn = Button("Delete") self.deleteBtn.setEnabled(False) self.add(self.userGrid) self.add(self.newBtn) self.add(self.deleteBtn) return
def __init__(self, key, title, content): AbsolutePanel.__init__(self) self.edit_header = Label("Edit a Post", StyleName="header_label") self.edit_title_label = Label("Title:") self.edit_title = TextBox() self.edit_title.setMaxLength(255) self.edit_content = TextArea() self.edit_content.setVisibleLines(2) self.edit_button = Button("Save") self.edit_cancel_button = Button("Cancel") self.edit_hidden_key = Hidden() self.error_message_label = Label("", StyleName="error_message_label") edit_contents = VerticalPanel(StyleName="Contents", Spacing=4) edit_contents.add(self.edit_header) edit_contents.add(self.edit_title_label) edit_contents.add(self.edit_title) edit_contents.add(self.edit_content) edit_contents.add(self.edit_button) edit_contents.add(self.edit_cancel_button) edit_contents.add(self.error_message_label) edit_contents.add(self.edit_hidden_key) self.edit_dialog = DialogBox(glass=True) self.edit_dialog.setHTML('<b>Blog Post Form</b>') self.edit_dialog.setWidget(edit_contents) left = (Window.getClientWidth() - 900) / 2 + Window.getScrollLeft() top = (Window.getClientHeight() - 600) / 2 + Window.getScrollTop() self.edit_dialog.setPopupPosition(left, top) self.edit_dialog.hide()
def __init__(self,parent): AbsolutePanel.__init__(self) self.userGrid = Grid() self.userGrid.createGrid(6, 6) self.userGrid.addTableListener(self) self.userGrid.setBorderWidth(2) self.userGrid.setCellPadding(4) self.userGrid.setCellSpacing(1) self.userGrid.setColLabelValue(0,"Username") self.userGrid.setColLabelValue(1,"First Name") self.userGrid.setColLabelValue(2,"Last Name") self.userGrid.setColLabelValue(3,"Email") self.userGrid.setColLabelValue(4,"Department") self.userGrid.setColLabelValue(5,"Password") self.newBtn = Button("New") self.deleteBtn = Button("Delete") self.deleteBtn.setEnabled(False) self.add(self.userGrid) self.add(self.newBtn) self.add(self.deleteBtn) return
def __init__(self,parent): AbsolutePanel.__init__(self) self.roleList = ListBox() self.roleList.setWidth('300px') self.roleList.setVisibleItemCount(6) self.roleList.addChangeListener(self.onListChange) #self.roleList.addKeyboardListener(self) self.roleCombo = ListBox() self.roleCombo.addKeyboardListener(self) self.roleCombo.addChangeListener(self.onComboChange) self.addBtn = Button("Add") self.addBtn.setEnabled(False) self.removeBtn = Button("Remove") self.removeBtn.setEnabled(False) vpanel = VerticalPanel() vpanel.add(self.roleList) hpanel = HorizontalPanel() hpanel.add(self.roleCombo) hpanel.add(self.addBtn) hpanel.add(self.removeBtn) vpanel.add(hpanel) self.add(vpanel) self.clearForm() return
def __init__(self, width, height): AbsolutePanel.__init__(self) self.setWidth(width) self.setHeight(height) self.window = {} self.window_zindex = {}
def __init__(self,parent): AbsolutePanel.__init__(self) ftable = FlexTable() ftable.setWidget(0, 0, Label("First Name", wordWrap=False)) ftableFormatter = ftable.getFlexCellFormatter() self.firstInput = TextBox() self.firstInput.addChangeListener(self.checkValid) self.firstInput.addKeyboardListener(self) ftable.setWidget(0, 1, self.firstInput) ftable.setWidget(1, 0, Label("Last Name", wordWrap=False)) self.lastInput = TextBox() self.lastInput.addChangeListener(self.checkValid) self.lastInput.addKeyboardListener(self) ftable.setWidget(1, 1, self.lastInput) ftable.setWidget(2, 0, Label("Email", wordWrap=False)) self.emailInput = TextBox() self.emailInput.addChangeListener(self.checkValid) self.emailInput.addKeyboardListener(self) ftable.setWidget(2, 1, self.emailInput) ftable.setWidget(3, 0, Label("Username", wordWrap=False)) self.usernameInput = TextBox() self.usernameInput.addChangeListener(self.checkValid) self.usernameInput.addKeyboardListener(self) ftable.setWidget(3, 1, self.usernameInput) ftable.setWidget(4, 0, Label("Password", wordWrap=False)) self.passwordInput = PasswordTextBox() self.passwordInput.addChangeListener(self.checkValid) self.passwordInput.addKeyboardListener(self) ftable.setWidget(4, 1, self.passwordInput) ftable.setWidget(5, 0, Label("Confirm", wordWrap=False)) self.confirmInput = PasswordTextBox() self.confirmInput.addChangeListener(self.checkValid) self.confirmInput.addKeyboardListener(self) ftable.setWidget(5, 1, self.confirmInput) ftable.setWidget(6, 0, Label("Department", wordWrap=False)) self.departmentCombo = ListBox() self.departmentCombo.addChangeListener(self.checkValid) self.departmentCombo.addKeyboardListener(self) ftable.setWidget(6, 1, self.departmentCombo) hpanel = HorizontalPanel() self.addBtn = Button("Add User", self.onAdd) self.addBtn.setEnabled(False) hpanel.add(self.addBtn) self.cancelBtn = Button("Cancel", self.onCancel) hpanel.add(self.cancelBtn) ftable.setWidget(7, 0, hpanel) ftableFormatter.setColSpan(7, 0, 2) self.add(ftable) return
def __init__(self,parent): AbsolutePanel.__init__(self) ftable = FlexTable() ftable.setWidget(0, 0, Label("First Name", wordWrap=False)) ftableFormatter = ftable.getFlexCellFormatter() self.firstInput = TextBox() self.firstInput.addChangeListener(self.checkValid) self.firstInput.addKeyboardListener(self) ftable.setWidget(0, 1, self.firstInput) ftable.setWidget(1, 0, Label("Last Name", wordWrap=False)) self.lastInput = TextBox() self.lastInput.addChangeListener(self.checkValid) self.lastInput.addKeyboardListener(self) ftable.setWidget(1, 1, self.lastInput) ftable.setWidget(2, 0, Label("Email", wordWrap=False)) self.emailInput = TextBox() self.emailInput.addChangeListener(self.checkValid) self.emailInput.addKeyboardListener(self) ftable.setWidget(2, 1, self.emailInput) ftable.setWidget(3, 0, Label("Username", wordWrap=False)) self.usernameInput = TextBox() self.usernameInput.addChangeListener(self.checkValid) self.usernameInput.addKeyboardListener(self) ftable.setWidget(3, 1, self.usernameInput) ftable.setWidget(4, 0, Label("Password", wordWrap=False)) self.passwordInput = PasswordTextBox() self.passwordInput.addChangeListener(self.checkValid) self.passwordInput.addKeyboardListener(self) ftable.setWidget(4, 1, self.passwordInput) ftable.setWidget(5, 0, Label("Confirm", wordWrap=False)) self.confirmInput = PasswordTextBox() self.confirmInput.addChangeListener(self.checkValid) self.confirmInput.addKeyboardListener(self) ftable.setWidget(5, 1, self.confirmInput) ftable.setWidget(6, 0, Label("Department", wordWrap=False)) self.departmentCombo = ListBox() self.departmentCombo.addChangeListener(self.checkValid) self.departmentCombo.addKeyboardListener(self) ftable.setWidget(6, 1, self.departmentCombo) hpanel = HorizontalPanel() self.addBtn = Button("Add User") self.addBtn.setEnabled(False) hpanel.add(self.addBtn) self.cancelBtn = Button("Cancel") hpanel.add(self.cancelBtn) ftable.setWidget(7, 0, hpanel) ftableFormatter.setColSpan(7, 0, 2) self.add(ftable) return
def __init__(self, Element=None, **kwargs): if Element is not None: kwargs['Element'] = Element AbsolutePanel.__init__(self, **kwargs) if Element is None: # avoid having CSS styles position:relative and hidden set on body Element = self.getBodyElement() self.setElement(Element) self.onAttach()
def __init__(self, parent): AbsolutePanel.__init__(self) self.home_header = Label("Blogjamas", StyleName="header_label") self.write_button = Button("Write a Post") self.edit_hidden_button = Button("", StyleName="hidden_button") self.delete_hidden_button = Button("", StyleName="hidden_button") self.add(self.home_header) self.add(self.write_button) self.add(self.edit_hidden_button) self.add(self.delete_hidden_button)
def __init__(self, vertical=False, **kwargs): # set defaults if not 'StyleName' in kwargs: if vertical: # vertical split panel kwargs['StyleName'] = "gwt-VerticalSplitPanel" else: kwargs['StyleName'] = "gwt-HorizontalSplitPanel" # splitter drag state vars self._drag_start = None self._pos = "50%" # orientation self._vertical = vertical # now init the bases AbsolutePanel.__init__(self, **kwargs) MouseHandler.__init__(self) # add our event support? self.addListenedEvent("Resize") # create the top/left widget container self._container1 = ScrollPanel() # create the bottom/right widget container self._container2 = ScrollPanel() # create the splitter self._splitter = SplitPanelSplitter(self) # add splitter handling self._splitter.addMouseListener(self) # add mouse event handling self.addMouseListener(self) # add the parts AbsolutePanel.add(self, self._container1, 0, 0) AbsolutePanel.add(self, self._splitter, 0, 0) AbsolutePanel.add(self, self._container2, 0, 0) # set the layout if vertical: # vertical split panel self._splitter.setStyleName("vsplitter") self._splitter.setWidth("100%") self._container1.setWidth("100%") self._container2.setWidth("100%") # set drag cursor DOM.setStyleAttribute(self._splitter.getElement(), "cursor", "n-resize") else: # horizontal split panel self._splitter.setStyleName("hsplitter") self._splitter.setHeight("100%") self._container1.setHeight("100%") self._container2.setHeight("100%") # set drag cursor DOM.setStyleAttribute(self._splitter.getElement(), "cursor", "e-resize")
def __init__(self, cols, rows, width, height): AbsolutePanel.__init__(self) self.rows = rows self.cols = cols self.setStyleName("gwt-TextWindow") DOM.setStyleAttribute(self.getElement(), 'fontFamily', 'monospace') self.setHeight(height) self.setWidth(width) self.text = {} for x in range(self.cols): self.text[x] = {}
def __init__(self): AbsolutePanel.__init__(self) self.page = 0 self.min_page = 1 self.max_page = 10 self.addb = Button("Next >", self) self.subb = Button("< Prev", self) self.g = Grid() self.g.resize(5, 5) self.g.setHTML(0, 0, "<b>Grid Test</b>") self.g.setBorderWidth(2) self.g.setCellPadding(4) self.g.setCellSpacing(1) self.updatePageDisplay() self.add(self.subb) self.add(self.addb) self.add(self.g)
def __init__(self): AbsolutePanel.__init__(self) self.page=0 self.min_page=1 self.max_page=10 self.addb=Button("Next >", self) self.subb=Button("< Prev", self) self.g=Grid() self.g.resize(5, 5) self.g.setHTML(0, 0, "<b>Grid Test</b>") self.g.setBorderWidth(2) self.g.setCellPadding(4) self.g.setCellSpacing(1) self.updatePageDisplay() self.add(self.subb) self.add(self.addb) self.add(self.g)
def __init__(self, parent): AbsolutePanel.__init__(self) self.post_header = Label("Write a Post", StyleName="header_label") self.post_write_title_label = Label("Title:") self.post_title = TextBox() self.post_content = TextArea() self.post_button = Button("Post") self.cancel_button = Button("Cancel") self.error_message_label = Label("", StyleName="error_message_label") contents = VerticalPanel(StyleName="Contents", Spacing=4) contents.add(self.post_header) contents.add(self.post_write_title_label) contents.add(self.post_title) contents.add(self.post_content) contents.add(self.post_button) contents.add(self.cancel_button) contents.add(self.error_message_label) self.dialog = DialogBox(glass=True) self.dialog.setHTML('<b>Blog Post Form</b>') self.dialog.setWidget(contents) left = (Window.getClientWidth() - 900) / 2 + Window.getScrollLeft() top = (Window.getClientHeight() - 600) / 2 + Window.getScrollTop() self.dialog.setPopupPosition(left, top) self.dialog.hide()
def __init__(self): self.state = State() self.game_over = False self.TD_CONSTS = {'c3': 0.767944, 'c2': 1.049451, 'c1': 3.074038, 'c6': 0.220823, 'c5': 0.281883, 'c4': 0.605861} AbsolutePanel.__init__(self) StyleSheetCssText(margins) # initialize css... self.welcome_label = HTML('<H2 align="center">Welcome to Meta-Tic-Tac-Toe!</H2><p>Play first by clicking on one of the positions in the middle board or let the AI go first by clicking on "AI first". To change the difficulty click on "Increase/Decrease search depth". Note: if there is a pop-up saying that the script is taking a long time to complete, this is not a bug - the AI is just taking a while to find the next move. Select the option to continue the script.</p>', StyleName='margins_both') self.add(self.welcome_label) self.depthLimit = 3 self.human_first = True self.ai_first = Button("AI first.", self, StyleName='margins_left') self.add(self.ai_first) self.increase_depth = Button("Increase search depth", self) self.decrease_depth = Button("Decrease search depth", self) self.depth_label = HTML("""AI will search to a <a href="#depth_explanation">depth</a> of """ + str(self.depthLimit) +".") self.depth_grid = Grid(StyleName='margins_left') self.depth_grid.resize(1, 3) self.depth_grid.setBorderWidth(2) self.depth_grid.setCellPadding(9) self.depth_grid.setCellSpacing(1) self.add(self.depth_grid) self.depth_grid.setWidget(0, 0, self.decrease_depth) self.depth_grid.setWidget(0, 1, self.depth_label) self.depth_grid.setWidget(0, 2, self.increase_depth) self.new_game = Button("New game", self, StyleName='margins_left') self.add(self.new_game) self.score_label = Label("CURRENT SCORE: Human: %d | AI: %d"% (0,0), StyleName='margins_left') self.add(self.score_label) self.game_over_msg = HTML("", StyleName='margins_left') self.add(self.game_over_msg) # initialize the board grid: self.g=Grid(StyleName='margins_left') self.g.resize(3, 3) self.g.setBorderWidth(2) self.g.setCellPadding(9) self.g.setCellSpacing(1) self.init() self.add(self.g) # initialize the contstants adjustment grid: self.adj_grid = Grid(StyleName='margins_left') self.adj_grid.resize(7, 3) self.adj_grid.setBorderWidth(2) self.adj_grid.setCellPadding(9) self.adj_grid.setCellSpacing(1) self.init_constants_adj_grid() self.add(self.adj_grid) self.max_player = '-1' self.min_player = '-1' self.state_to_grid()
def __init__(self): self.state = State() self.game_round = 0 self.TD_CONSTS = { 'c3': 1., 'c2': 1., 'c1': 1., 'c6': 1., 'c5': 1., 'c4': 1. } self.CONSTS = { 'c3': .5, 'c2': 1., 'c1': 3., 'c6': .5, 'c5': .5, 'c4': .5 } self.BEST_CONSTANTS = { 'c3': 0.767944, 'c2': 1.049451, 'c1': 3.074038, 'c6': 0.220823, 'c5': 0.281883, 'c4': 0.605861 } self.ONES_CONSTS = { 'c3': 1., 'c2': 1., 'c1': 1., 'c6': 1., 'c5': 1., 'c4': 1. } AbsolutePanel.__init__(self) self.welcome_label = HTML( '<H2 align="center">Welcome to Meta-Tic-Tac-Toe!</H2>To watch the AI play itself, press either "begin game" button. Note: if there is a pop-up saying that the script is taking a long time to complete, this is not a bug - the AI is just taking a while to find the next move. Select the option to continue the script.', StyleName='margins_both') self.add(self.welcome_label) self.depth_limit = 2 self.train_td = Button("Begin game. Learning AI first!", self, StyleName='margins_left') self.add(self.train_td) self.train_static = Button("Begin game. Static AI first!", self, StyleName='margins_left') self.add(self.train_static) self.score_label = Label( "CURRENT SCORE: Learning AI: %d | Static AI: %d" % (0, 0), StyleName='margins_left') self.add(self.score_label) self.game_over_message = Label("", StyleName='margins_left') self.add(self.game_over_message) StyleSheetCssText(margins) self.increase_depth = Button("Increase ply search depth.", self) self.decrease_depth = Button("Decrease ply search depth.", self) self.depth_label = Label("Current depth is " + str(self.depth_limit) + ".") self.depth_grid = Grid(StyleName='margins_left') self.depth_grid.resize(1, 3) self.depth_grid.setBorderWidth(2) self.depth_grid.setCellPadding(9) self.depth_grid.setCellSpacing(1) self.add(self.depth_grid) self.depth_grid.setWidget(0, 0, self.decrease_depth) self.depth_grid.setWidget(0, 1, self.depth_label) self.depth_grid.setWidget(0, 2, self.increase_depth) # initialize the board grid: self.g = Grid(StyleName='margins_left') self.g.resize(3, 3) self.g.setBorderWidth(2) self.g.setCellPadding(9) self.g.setCellSpacing(1) self.init() self.add(self.g) # initialize the contstants adjustment grid: self.adj_grid = Grid(StyleName='margins_left') self.adj_grid.resize(7, 4) self.adj_grid.setBorderWidth(2) self.adj_grid.setCellPadding(9) self.adj_grid.setCellSpacing(1) self.init_constants_adj_grid() self.add(self.adj_grid) self.reset_constants = Button( "Reset all of Learning AI's constants to 1.", self, StyleName='margins_left') self.add(self.reset_constants) self.state_to_grid()
def __init__(self): self.state = State() self.game_round = 0 self.TD_CONSTS = {'c3': 1., 'c2': 1., 'c1': 1., 'c6': 1., 'c5': 1., 'c4': 1.} self.CONSTS = {'c3': .5, 'c2': 1., 'c1': 3., 'c6': .5, 'c5': .5, 'c4': .5} self.BEST_CONSTANTS = {'c3': 0.767944, 'c2': 1.049451, 'c1': 3.074038, 'c6': 0.220823, 'c5': 0.281883, 'c4': 0.605861} self.ONES_CONSTS = {'c3': 1., 'c2': 1., 'c1': 1., 'c6': 1., 'c5': 1., 'c4': 1.} AbsolutePanel.__init__(self) self.welcome_label = HTML('<H2 align="center">Welcome to Meta-Tic-Tac-Toe!</H2>To watch the AI play itself, press either "begin game" button. Note: if there is a pop-up saying that the script is taking a long time to complete, this is not a bug - the AI is just taking a while to find the next move. Select the option to continue the script.', StyleName='margins_both') self.add(self.welcome_label) self.depth_limit = 2 self.train_td = Button("Begin game. Learning AI first!", self, StyleName='margins_left') self.add(self.train_td) self.train_static = Button("Begin game. Static AI first!", self, StyleName='margins_left') self.add(self.train_static) self.score_label = Label("CURRENT SCORE: Learning AI: %d | Static AI: %d"% (0,0), StyleName='margins_left') self.add(self.score_label) self.game_over_message = Label("", StyleName='margins_left') self.add(self.game_over_message) StyleSheetCssText(margins) self.increase_depth = Button("Increase ply search depth.", self) self.decrease_depth = Button("Decrease ply search depth.", self) self.depth_label = Label("Current depth is " + str(self.depth_limit) +".") self.depth_grid = Grid(StyleName='margins_left') self.depth_grid.resize(1, 3) self.depth_grid.setBorderWidth(2) self.depth_grid.setCellPadding(9) self.depth_grid.setCellSpacing(1) self.add(self.depth_grid) self.depth_grid.setWidget(0, 0, self.decrease_depth) self.depth_grid.setWidget(0, 1, self.depth_label) self.depth_grid.setWidget(0, 2, self.increase_depth) # initialize the board grid: self.g=Grid(StyleName='margins_left') self.g.resize(3, 3) self.g.setBorderWidth(2) self.g.setCellPadding(9) self.g.setCellSpacing(1) self.init() self.add(self.g) # initialize the contstants adjustment grid: self.adj_grid = Grid(StyleName='margins_left') self.adj_grid.resize(7, 4) self.adj_grid.setBorderWidth(2) self.adj_grid.setCellPadding(9) self.adj_grid.setCellSpacing(1) self.init_constants_adj_grid() self.add(self.adj_grid) self.reset_constants = Button("Reset all of Learning AI's constants to 1.", self, StyleName='margins_left') self.add(self.reset_constants) self.state_to_grid()