Skip to content

Commit

Permalink
修复:解决makeData时有黑框闪动的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
xtf0214 committed Jul 15, 2023
1 parent cce1ed7 commit c1b6459
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
10 changes: 7 additions & 3 deletions ProgramCompareUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def __del__(self):
def compare(self, id: int = 1, show_input=True, show_output=True):
# 产生样例输入
with open(f'test{id}.in', 'w') as file:
self.setData(file, id)
writeln = lambda a : file.write(' '.join(map(str, a)) + '\n')
self.setData(writeln, id)
# 获取样例答案和样例输出
std_out = os.popen(self.std_exe + ' < ' + f'test{id}.in').read()
cmp_out = os.popen(self.cmp_exe + ' < ' + f'test{id}.in').read()
Expand All @@ -50,5 +51,8 @@ def compare(self, id: int = 1, show_input=True, show_output=True):
def makeData(self, id: int = 1):
# 使用setData产生样例输入并用std_exe产生样例答案
with open(f'test{id}.in', 'w') as file:
self.setData(file, id)
os.system(f'{self.std_exe} < test{id}.in > test{id}.out')
writeln = lambda a : file.write(' '.join(map(str, a)) + '\n')
self.setData(writeln, id)
with open(f'test{id}.out', 'w') as file:
std_out = os.popen(self.std_exe + ' < ' + f'test{id}.in').read()
file.write(std_out)
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
# program-compare-UI

A program-comparer Based on PyQt5.

## Usage

![](img/GUI.png)

### prepare `setData.py`

`writeln` Pass in a list and write it on one line.

```python
from random import randint


def randPair(a, b):
l = randint(a, b)
r = randint(a, b)
return (l, r) if l < r else (r, l)


def setData(writeln, id=1):
a = randint(1, 2e9)
b = randint(1, 2e9)
writeln([a, b])
```

# program-compare

This is a program-comparer for programming competition. It's base on `cyaron`, but some simple encapsulation was made.
Expand Down
14 changes: 8 additions & 6 deletions setData.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from io import TextIOWrapper
from random import randint


def setData(file: TextIOWrapper, id=1):
write = lambda *x: file.write(' '.join([str(i) for i in x]) + ' ')
writeln = lambda *x: file.write(' '.join([str(i) for i in x]) + '\n')
###################
def randPair(a, b):
l = randint(a, b)
r = randint(a, b)
return (l, r) if l < r else (r, l)


def setData(writeln, id=1):
a = randint(1, 2e9)
b = randint(1, 2e9)
writeln(a, b)
writeln([a, b])

0 comments on commit c1b6459

Please sign in to comment.