Spaces:
Runtime error
Runtime error
Update app.py
Browse files268 unmodified lines26927027127227327427584 unmodified lines360361362363364365366168 unmodified lines535536537538539540541542543544545546547548549550268 unmodified linesself.last_clicked_atom = Noneself.mode = "draw" # 重置模式def add_at极om(self, x, y, symbol):"""添加原子到指定位置"""atom = Chem.Atom(symbol)atom_idx = self.mol.AddAtom(atom)84 unmodified linesreturn Truereturn Falsedef find_nearest_atom(self, x, y, threshold=40):"""在分子中找到距离点击位置最近的原子"""if not self.atoms:return None168 unmodified linesmode_text = f"Mode: {self.mode.capitalize()}"draw.text((10, 10), mode_text, fill="blue", font=font)# 如果选择模式下有选中的原子,额外绘制红色边框if self.mode == "select" and self.selected_atom is not None:if self.selected_atom in self.atoms:x, y, _ = self.atoms[self.selected_atom]# 绘制红色圆圈表示选中draw.ellipse([(x-25, y-25), (x+25, y+25)],outline="red",width=3)return img268 unmodified lines26927027127227327427584 unmodified lines360361362363364365366168 unmodified lines535536537538539540268 unmodified linesself.last_clicked_atom = Noneself.mode = "draw" # 重置模式def add_atom(self, x, y, symbol):"""添加原子到指定位置"""atom = Chem.Atom(symbol)atom_idx = self.mol.AddAtom(atom)84 unmodified linesreturn Truereturn Falsedef find_nearest_atom(self, x, y, threshold=20):"""在分子中找到距离点击位置最近的原子"""if not self.atoms:return None168 unmodified linesmode_text = f"Mode: {self.mode.capitalize()}"draw.text((10, 10), mode_text, fill="blue", font=font)return img
app.py+2-12