Example #1
0
    def init_board(self):

        board = []

        for x in range(0, self.screen_size, self.screen_size // 9):

            for y in range(0, self.screen_size, self.screen_size // 9):

                # Draw border of the squares
                if x % 3 == 0 and y % 3 == 0:
                    pygame.draw.rect(
                        self.screen, color.GRAY,
                        Rect(x + self.border, y + self.border, self.squares[0],
                             self.squares[0]))

                num = self.sudoku.board[x // 100][y // 100]

                # Create input boxes
                if num > 0:
                    inputbox = InputBox(x, y, self.squares[1], self.squares[1],
                                        self.border, str(num), True)
                else:
                    inputbox = InputBox(x, y, self.squares[1], self.squares[1],
                                        self.border)

                # Append new InputBox into an array
                board.append(inputbox)

        return board
Example #2
0
def automatic_control(argname, default):
    if isinstance(default, Control):
        default.set_argname(argname)
        return default
    from inputbox import InputBox
    i = InputBox(default=default, type=eval)
    i.set_argname(argname)
    return i
Example #3
0
 def printhelp(self, grid, start, secs):
     helpfile = open('pygamehelp')
     inbox = InputBox(self.screen,
                      boxw=260,
                      boxh=220,
                      cb=self.pstats,
                      cbargs=(grid, start, secs))
     val = inbox.show(helpfile.read())
     if val:
         if val.type == pygame.QUIT:
             return 'quit'
Example #4
0
 def changename(self, name):
     if not name:
         name = ''
     inbox = InputBox(self.screen)
     cnresult = inbox.ask("Level Name", text=name)
     if not cnresult:
         return
     if type(cnresult) is not str:
         if cnresult.type == pygame.QUIT:
             return ('control', 'quit')
     return cnresult
Example #5
0
    def __init__(self, msg, callbackOnConfrim, emergency=0, default="", **dargs):
        """
        msg: the prompt message
        default: the default input text
        callbackOnConfrim: shoud be a function with the inputed string as the argument
        """
        self.emergency = emergency
        root = Root.instance
        size = 400, 260
        super(Dialog, self).__init__(
            root,
            size=size,
            pos=((root.size[0] - size[0]) / 2, (root.size[1] - size[1]) / 2),
            bgcolor=(0x9F, 0xAF, 0xFF, 0xFF),
            level=Root.DIALOG_LEVEL,
            **dargs
        )
        self.msgbox = TextBox(
            self, text=msg, pos=(5, 5), size=(390, 200), bgcolor=(0, 0, 0, 0x88), color=(0xFF, 0xFF, 0xFF), fontsize=14
        )
        self.input = InputBox(self, text=default, pos=(5, 210), size=(390, 20))
        btn_confirm = Button(self, pos=(5, 235), caption="confirm", size=(100, 20))
        btn_cancel = Button(self, pos=(295, 235), caption="cancel", size=(100, 20))

        self.callbackOnConfrim = callbackOnConfrim
        btn_confirm.bind_command(self.confirm)
        btn_cancel.bind_command(self.cancel)
        self.bind_key(K_ESCAPE, self.cancel)

        self.input.set_as_focus()
 def AddItem(self, sender, e):
     input = InputBox()
     result = input.ShowDialog()
     if result == DialogResult.OK:
         text = input._textBox.Text
         if text:
             mesgresult = MessageBox.Show(
                 text +
                 " will be added to the BlackList.\n\nWould you also like to remove any occurences of this publisher from the already downloaded data?\n\n(Clicking Cancel will not add this publisher to the BlackList)",
                 "Delete existing?", MessageBoxButtons.YesNoCancel,
                 MessageBoxIcon.Question)
             if mesgresult == DialogResult.Yes:
                 self._blacklistdisplay.Items.Add(text)
                 self.ComicList.RemovePublisher(text)
             elif mesgresult == DialogResult.No:
                 self._blacklistdisplay.Items.Add(text)
     input.Dispose()
Example #7
0
def question(q,
             pos,
             size=(300, 50),
             fontsize=fontSize,
             allowanswer=1,
             default='',
             waitForAnswer=1):
    qsurf = InputBox(screen,
                     pos,
                     size,
                     q,
                     allowanswer,
                     fontsize=fontsize,
                     a=default)
    pygame.display.update()
    finished = 0
    answer = None
    if waitForAnswer:
        while not finished:
            for event in pygame.event.get():
                finished, answer = qsurf.handle_event(event)
                qsurf.draw(screen)
                pygame.display.update()
    return answer
Example #8
0
def show_popup(task, textPosition):
    Log("Open Pop up input screen")
    background = SCREEN.copy()
    input = InputBox((360,268), BUFFER, color=[(179,179,179),(0,186,220),(179,179,179)],font_color=FONT_COLOR_POPUP, max_size=280, enable_rows = False)
    input.makeFocus()
    text = pygame.font.Font( FONT, FONT_SIZE ).render(task , True, (0,0,0) )
    running = True
    while running:
        mouseX, mouseY = pygame.mouse.get_pos()
        CLEAR(BUFFER)
        SCREEN.blit(background,(0,0))
        SCREEN.blit(PIC_POPUP,(0,0))
        SCREEN.blit(text,textPosition)
        SCREEN.blit(PIC_OK_BTN_UP, (393, 300))
        SCREEN.blit(PIC_CANCEL_BTN_UP, (520, 300))  
        
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                if show_security():
                    sys.exit()
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_RETURN:
                    running = False
            #Left mouseclick on OK button
            if event.type == pygame.MOUSEBUTTONDOWN and mouse_in_area(mouseX, mouseY, 393, 300, 87, 28) and  event.button == 1: 
                SCREEN.blit(PIC_OK_BTN_DOWN, (393, 300))            
            if event.type == pygame.MOUSEBUTTONUP and mouse_in_area(mouseX, mouseY, 393, 300, 87, 28) and  event.button == 1:
                running = False
            #Left mouseclick on CANCEL button
            if event.type == pygame.MOUSEBUTTONDOWN and mouse_in_area(mouseX, mouseY, 520, 300, 87, 28) and  event.button == 1: 
                SCREEN.blit(PIC_CANCEL_BTN_DOWN, (520, 300)) 
            if event.type == pygame.MOUSEBUTTONUP and mouse_in_area(mouseX, mouseY, 520, 300, 87, 28) and  event.button == 1:
                return None
            input.handleEvent(event)
            
        input.update(SCREEN)
        pygame.display.update()
    return input.getString()
Example #9
0
            recv_message(msg_split)
    else:    
        recv_message(msg)

def penalty(queue, t):
    for i in range(t, 0, -1):
        queue.put(i)
        time.sleep(1)
    queue.put(0)
cards_obj = []

Thread(target = sock_recv, args = [clientSocket,input_queue]).start()
screen = pygame.display.set_mode((1400, 700))
pygame.draw.rect(screen, (0, 0, 30), pygame.Rect(550, 100, 300, 400 ), 0)
pygame.draw.rect(screen, (255, 255, 255), pygame.Rect(550, 100, 300, 400), 1)
input_username = InputBox(600, 300, 200, 40, defaultText="username")
input_password = InputBox(600, 350, 200, 40, defaultText="password",password=True)
login_button = Button(screen,(100, 575), (575, 100), "Login", (250, 0, 0), (0, 0, 30), False, 36)
register_button = Button(screen, (725, 575), (575, 100), "Register", (250, 0, 0), (0, 0, 30), False, 36)
input_boxes = [input_username,input_password]
startScreen(screen,(100, 50), (1200, 500),input_boxes,[login_button,register_button])

while not loggedIn:
    for event in pygame.event.get():

        if event.type == pygame.QUIT:
            clientSocket.send("QUIT|{}".format(str(user)).encode("utf-8"))
            clientSocket.close()
            pygame.quit() 
            sys.exit()
        for box in input_boxes:
Example #10
0
def game_over():
    score_list = get_scoreboard()
    good_run = is_good_run(score_list)

    large_text = LARGE_FONT.render("Game Over", True, PURPLE)
    text_rect = large_text.get_rect()
    text_rect.center = (window_width // 2, window_height // 2 - 100)
    window.blit(large_text, text_rect)

    restart_button = Button("Restart", window_width // 2 + 50, 500, 100, 200,
                            PURPLE, GREEN, BLACK, 40)
    menu_button = Button("Main Menu", window_width // 2 - 250, 500, 100, 200,
                         PURPLE, GREEN, BLACK, 40)

    if good_run:
        input_box = InputBox(window_width // 2, 420, 130, 30)
        text = None

        name_text = SMALL_FONT.render("Enter your name: ", True, PURPLE)
        text_rect = name_text.get_rect()
        text_rect.center = (window_width // 2, window_height // 2)
        window.blit(name_text, text_rect)

        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    quit()

                text = input_box.handle_event(event)
            if text:
                update_scoreboard(score_list, text)

            input_box.draw(window)

            mouse_pos = pygame.mouse.get_pos()
            mouse_clicks = pygame.mouse.get_pressed()
            restart_button.draw(mouse_pos, window)
            menu_button.draw(mouse_pos, window)

            if restart_button.is_clicked(mouse_pos, mouse_clicks):
                main_game()
            elif menu_button.is_clicked(mouse_pos, mouse_clicks):
                game_menu(True)

            pygame.display.update()
            clock.tick(15)
    else:
        while True:
            for event in pygame.event.get():
                if event.type == pygame.QUIT:
                    pygame.quit()
                    quit()

            mouse_pos = pygame.mouse.get_pos()
            mouse_clicks = pygame.mouse.get_pressed()
            restart_button.draw(mouse_pos, window)
            menu_button.draw(mouse_pos, window)

            if restart_button.is_clicked(mouse_pos, mouse_clicks):
                main_game()
            elif menu_button.is_clicked(mouse_pos, mouse_clicks):
                game_menu(True)

            keys = pygame.key.get_pressed()
            if keys[pygame.K_r]:
                main_game()

            pygame.display.update()
            clock.tick(15)
Example #11
0
# Create the full set of tabs at the top of the screen
tabs = TabBar(["Main Menu", "Tables", "Query", "Help"], SELECTED_COLOR, DESELECTED_TAB_COLOR)
inTab = "Main Menu"
switchTab = True

# Create Tables menu
if connected:
	tableNames = db.getTables()
	tableMenu = Menu(3, 0, curses.LINES - 3, 15, tableNames, True, SELECTED_COLOR)
	tableMenu.hide()
	
# Create textBox for edit-able input
inputY = 2
inputPrompt = "\n   Enter Query: \n(ctr-g to submit)"
max_lines = curses.LINES - 10
inputBox = InputBox(inputPrompt, inputY, 0, max_lines)
(y, inputX) = inputBox.getboxyx()

# Create pane for displaying results based on input	
(inputYmax, x) = inputBox.getmaxyx()
w = curses.COLS
paneYwithInput = inputY + inputYmax + 1
h = curses.LINES - paneYwithInput
resultsWin = curses.newwin(h, w, paneYwithInput, 0)
resultsPane = ResultsPane(resultsWin)

# Create pane for non-input pages
mainPaneWin = curses.newwin(curses.LINES - 3, curses.COLS - 16, 3, 16)
mainPane = ResultsPane(mainPaneWin)

# Create buttons for Help tab
Example #12
0
coloredlogs.install(level='DEBUG')

WIDTH = 1024
HEIGHT = 768
FONT_NAME = "Arial"
FONT_SIZE = 36
WIN_CAPTION = "Doomsdash"
SERVER_URL = "127.0.0.1"
conn_status = b"NOT CONNECTED"
conn_color = pynk.lib.nk_rgb(255, 0, 0)

tb = NetworkTables.initialize(server=SERVER_URL)
#NetworkTables.enableVerboseLogging()
d_width = WIDTH
d_height = HEIGHT
data_box = InputBox(128)


def make_screen():
    return pygame.display.set_mode((d_width, d_height), pygame.RESIZABLE)


def connectionListener(connected, info):
    logging.info(str(info) + ": Connected={}".format(connected))
    if connected:
        global conn_status
        global conn_color
        conn_status = b"CONNECTED"
        conn_color = pynk.lib.nk_rgb(0, 255, 0)

def drawValues(ctx, inValues):