sample_box.py
bool bReturn = false;
string sDomainName = System.Environment.UserDomainName;
using (PrincipalContext oContext = new PrincipalContext(ContextType.Domain, sDomainName))
{
if (oContext.ValidateCredentials(sUserName, sPassword))
{
using (PrincipalSearcher oSearcher = new PrincipalSearcher(new UserPrincipal(oContext)))
{
oSearcher.QueryFilter.SamAccountName = sUserName;
Principal oPrincipal = oSearcher.FindOne();
foreach (Principal oPrin in oPrincipal.GetGroups())
{
if (oPrin.Name.Trim().ToString().Equals(sGroupName))
{
bReturn = true;
break;
}
}
}
}
pyth.py
gr=0
class SampBoxLayout(BoxLayout):
def input_rpm(self, instance, value):
if value is True:
global gr
gr=22
答案 0 :(得分:0)
尝试创建一个常量而不是普通变量:
GR = 0
然后将其导入:
import sample_box
要获取常量,请使用以下语法:
sample_box.GR
将此代码添加到您的代码中,以防止import语句运行sample_box.py:
GR = 0
if __name__ == "__main__":
# all your code that you don't want to run here