if event.type == pygame.MOUSEBUTTONDOWN:
if event.button == 1:
for i in range(CELL_WIDTH, 610, CELL_WIDTH):
for j in range(CELL_HEIGHT, 610, CELL_HEIGHT):
if (i+75,j) > event.pos > (i, j):
print(i,j)
>>> def read_blocks(fname, block_size):
... with open(fname, 'rb') as fin:
... while True:
... data = fin.read(block_size)
... if data:
... yield data
... else:
... break
...
>>> out = read_blocks('/etc/passwd', 8)
>>>
>>> list(out)[:5]
[b'root:x:0', b':0:root:', b'/root:/b', b'in/bash\n', b'bin:x:1:']
>>>
>>> out = read_blocks('/etc/passwd', 10)
>>>
>>> list(out)[:5]
[b'root:x:0:0', b':root:/roo', b't:/bin/bas', b'h\nbin:x:1:', b'1:bin:/bin']
>>>
class HBox4(QGridLayout):
def __init__(self, parent=None):
super(HBox4, self).__init__(parent)
self.table = TableWidget()
self.addWidget(self.table, *(0,0))
self.addWidget(TabDemo(), *(0,1))
def update(self,data):
self.table.update(data)
class TableWidget(QTableWidget):
def __init__(self, parent=None, data=[]):
super(TableWidget, self).__init__(parent)
#data = []
self.setColumnCount(1)
self.setRowCount(len(data))
for i, entry in enumerate(data, start=1):
self.setRowCount(i)
item = QTableWidgetItem()
item.setText(str(entry))
def update(self,data):
self.clearContents ()
#тут очищаем таблицу, затем тот же код, что и в init
self.setColumnCount(1)
self.setRowCount(len(data))
for i, entry in enumerate(data, start=1):
self.setRowCount(i)
item = QTableWidgetItem()
item.setText(str(entry))
#
d = []
with open(file, 'r') as f:
for i in f:
print(i)
d.append(i)
byte_count = 8
with open("myfile", "rb") as f:
byte = f.read(byte_count)
while byte != b"":
# Do stuff with byte.
byte = f.read(byte_count)
>>> new_list = [1, 2, 3, 4, 5, 6]
>>> new_list == sorted(new_list)
True
>>> new_list = [1, 2, 3, 4, 8, 6, 5]
>>> new_list == sorted(new_list)
False