checkA.php,pspell_check

{//depends on fnSpell()

// Extracts text from HTML code. In addition to normal word separators,  HTML tags

// and HTML entities also function as word delimiters$pspell_link=pspell_new("en");//0. Get the dictionary$strings=explode(">",$text);//1. Split $text on '>' to give us $strings with 0 or 1 HTML tags at the end$nStrings=count($strings);

for ($cStrings=0;$cStrings

{$string=$strings[$cStrings];//2. For each string from 1if ($string=='')

continue;$temp=explode('' to give us a $tag and $cdata$tag=$temp[1];$cdata=$temp[0];$subCdatas=explode(";",$cdata);//2.2 Split &cdata on ';' to give $subcdatas with 0 or 1 HTML entities on the end$nSubCdatas=count($subCdatas);//2.3   For each $subCdata from $subcdatas in 2.2for ($cSubCdatas=0;$cSubCdatas

{$subCdata=$subCdatas[$cSubCdatas];

if ($subCdata=='')

continue;$temp=explode('&',$subCdata);//2.3.1     Split the $subCdata on '&' to give us a $subCdataEntity and a $subCdataWithNoEntities$subCdataEntity=$temp[1];$subCdataWithNoEntities=$temp[0];$subCdataWithNoEntities=fnSpell($pspell_link,$subCdataWithNoEntities);//2.3.2     Spellcheck the $cdataWithNoEntitiesif (!$subCdataEntity)//2.3.3        Put the $subCdataEntity, a '&' and the $cdataWithNoEntities back into the $subCdata from 2.2$subCdata=$subCdataWithNoEntities;

else$subCdata=$subCdataWithNoEntities.'&'.$subCdataEntity.';';$subCdatas[$cSubCdatas] =$subCdata;//2.3.4        Put the $subCdata back into the array of $subCdatas}$cdata=implode("",$subCdatas);//2.4    Implode the array of $subCdatas back into the $cdataif ($tag)//2.5    Put the $tag , '>' and $cdata back into $string$string=$cdata.'';

else$string=$cdata;$strings[$cStrings] =$string;//2.6    Put $string back in its place in $strings}$text=implode('',$strings);//3  Implode the $strings back into $textreturn$text;

}

functionfnSpell($pspell_link,$string)

{preg_match_all("/[A-Z\']{1,16}/i",$string,$words);

for ($i=0;$i

{$currentword=$words[0][$i];

if (!pspell_check($pspell_link,$currentword))

{$wordarray=pspell_suggest($pspell_link,$currentword);$words=implode(', ',$wordarray);$suggest="$currentword";$string=str_replace($currentword,$suggest,$string);

}

}

return$string;

}

functionClearSpell($text)

{$strings=explode(">",$text);$nStrings=count($strings);

for ($cStrings=0;$cStrings

{$string=$strings[$cStrings];

if ($string=='')

continue;$temp=explode('

if (strstr($tag,'acronym') &&strstr($tag,"class='spell'") )$string=$cdata;

else$string=$cdata.'';$strings[$cStrings] =$string;

}$text=implode('',$strings);

return$text;

}?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
下面是一个示例代码,可以实现您的要求: ```python import sys from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QLabel, QComboBox, QCheckBox, QPushButton, QTableWidget, QTableWidgetItem, QVBoxLayout, QHBoxLayout, QTableWidgetItem, QGridLayout class MainWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("MainWindow") # 设置第一个Widget self.widget1 = QWidget() self.layout1 = QGridLayout(self.widget1) self.label1 = QLabel("textlabel1") self.combo1 = QComboBox() self.combo1.addItems(["Option 1", "Option 2", "Option 3"]) self.label2 = QLabel("textlabel2") self.check1 = QCheckBox("CheckBox1") self.check2 = QCheckBox("CheckBox2") self.label3 = QLabel("textlabel3") self.checkA = QCheckBox("CheckBoxA") self.checkB = QCheckBox("CheckBoxB") self.button = QPushButton("Show/Hide Second Widget") self.button.clicked.connect(self.show_hide_second_widget) self.layout1.addWidget(self.label1, 0, 0) self.layout1.addWidget(self.combo1, 0, 1) self.layout1.addWidget(self.label2, 1, 0) self.layout1.addWidget(self.check1, 1, 1) self.layout1.addWidget(self.check2, 1, 2) self.layout1.addWidget(self.label3, 2, 0) self.layout1.addWidget(self.checkA, 2, 1) self.layout1.addWidget(self.checkB, 2, 2) self.layout1.addWidget(self.button, 3, 0) # 设置第二个Widget self.widget2 = QWidget() self.layout2 = QVBoxLayout(self.widget2) self.table1 = QTableWidget() self.table1.setRowCount(3) self.table1.setColumnCount(2) self.table1.setHorizontalHeaderLabels(["CheckBox", "ComboBox"]) self.table2 = QTableWidget() self.table2.setRowCount(3) self.table2.setColumnCount(2) self.table2.setHorizontalHeaderLabels(["CheckBox", "ComboBox"]) self.table3 = QTableWidget() self.table3.setRowCount(3) self.table3.setColumnCount(2) self.table3.setHorizontalHeaderLabels(["CheckBox", "ComboBox"]) self.layout2.addWidget(self.table1) self.layout2.addWidget(self.table2) self.layout2.addWidget(self.table3) self.widget2.hide() # 设置MainWindow中的布局 self.central_widget = QWidget() self.central_layout = QHBoxLayout(self.central_widget) self.central_layout.addWidget(self.widget1) self.central_layout.addWidget(self.widget2) self.setCentralWidget(self.central_widget) def show_hide_second_widget(self): if self.widget2.isVisible(): self.widget2.hide() else: self.widget2.show() def print_values(self): print("Table 1:") for row in range(self.table1.rowCount()): cbox = self.table1.cellWidget(row, 0) combobox = self.table1.cellWidget(row, 1) print(cbox.text(), combobox.currentText()) print("Table 2:") for row in range(self.table2.rowCount()): cbox = self.table2.cellWidget(row, 0) combobox = self.table2.cellWidget(row, 1) print(cbox.text(), combobox.currentText()) print("Table 3:") for row in range(self.table3.rowCount()): cbox = self.table3.cellWidget(row, 0) combobox = self.table3.cellWidget(row, 1) print(cbox.text(), combobox.currentText()) app = QApplication(sys.argv) window = MainWindow() window.show() app.exec_() ``` 上面的代码中,第一个Widget使用了QGridLayout布局,第二个Widget使用了QVBoxLayout布局。在第二个Widget中,使用了三个QTableWidget来显示表格,每个表格都有两列,第一列是QCheckBox,第二列是QComboBox。在MainWindow中,使用了QHBoxLayout布局,将第一个Widget和第二个Widget放在一起。实现了点击按钮可以显示/隐藏第二个Widget。还实现了一个print_values方法,可以用来打印所有CheckBox和ComboBox的值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值