예제 #1
0
 def test_correct_text_edit(self):
     input_number = 0
     input_number2 = 1
     entry = widgets.TextEdit(self.root, input_number)
     entry2 = widgets.TextEdit(self.root, input_number2, readonly=True)
     self.assertNotEqual(
         entry.get_value(),
         str(input_number))  # it shouldn't be set if number is 0
     self.assertEqual(entry2.get_value(), str(input_number2))
     self.assertEqual(entry.cget("justify"), "center")
     self.assertEqual(type(entry.value), tkinter.StringVar)
     self.assertEqual(entry.cget("width"), variables.SUDOKU_SQUARE_SIZE)
     self.assertEqual(
         entry.cget("font"),
         variables.NUMBERS_FONT + " " + str(variables.NUMBERS_SIZE))
     self.assertEqual(entry.cget("state"), "normal")
     self.assertEqual(entry2.cget("state"), "readonly")
예제 #2
0
 def test_set_background(self):
     text_edit = widgets.TextEdit(self.root, 1)
     text_edit._set_background()
     self.assertEqual(
         text_edit.config("background")[4], variables.SQUARE_ERR_COLOR)
     text_edit._set_background()
     self.assertEqual(
         text_edit.config("background")[4], variables.SQUARE_COLOR)
예제 #3
0
 def test_limit_size(self):
     number = 1
     text_edit = widgets.TextEdit(self.root, number)
     text_edit.value.set("12")
     text_edit._limit_size()
     self.assertEqual(text_edit.get_value(), str(number))
     self.assertEqual(
         text_edit.config("background")[4], variables.SQUARE_COLOR)
     text_edit.value.set("a")
     self.assertEqual(text_edit.get_value(), "")
     self.assertEqual(
         text_edit.config("background")[4], variables.SQUARE_ERR_COLOR)
예제 #4
0
 def _generate_field(self):
     text_edits = []
     for y, row in enumerate(self.field_numbers):  # sudoku field is 9x9
         line = []
         for x, number in enumerate(row):
             text_edit = widgets.TextEdit(self.content_frame, number, readonly=self.readonly, row=y, column=x)
             if (len(self.detected) == 0 and number != 0) or (y * 9 + x) in self.detected:
                 text_edit.config(background="gray93")
                 text_edit.config(readonlybackground="gray85")
             line.append(text_edit)
         text_edits.append(line)
     return text_edits
예제 #5
0
 def test_correct_get_value(self):
     number = 3
     text_edit = widgets.TextEdit(self.root, number)
     self.assertEqual(text_edit.get_value(), str(number))