wxpython没有在centos上工作

时间:2016-05-05 18:25:32

标签: python wxpython

我只是关注here

中的教程
<?php  
$connect = mysqli_connect("db location","username","password", "forks") or die(mysql_error()); 


if(isset($_COOKIE['ID_your_site'])){ //if there is, it logs you in and directes you to the members page
    $username = $_COOKIE['ID_site']; 
    $pass = $_COOKIE['Key_site'];
    $check = mysqli_query($conect, "SELECT * FROM users WHERE username = '$username'")or die(mysql_error());

    while($info = mysqli_fetch_array( $check )){
        if ($pass != $info['password']){}
        else{
            header("Location: login.php");
        }
    }
 }

 //if the login form is submitted 
 if (isset($_POST['submit'])) {

    // makes sure they filled it in
    if(!$_POST['username']){
        die('You did not fill in a username.');
    }
    if(!$_POST['pass']){
        die('You did not fill in a password.');
    }

    // checks it against the database
    if (!get_magic_quotes_gpc()){
        $_POST['email'] = addslashes($_POST['email']);
    }

    $check = mysqli_query($conect, "SELECT * FROM users WHERE username = '".$_POST['username']."'")or die(mysql_error());

 //Gives error if user dosen't exist
 $check2 = mysqli_num_rows($check);
 if ($check2 == 0){
    die('That user does not exist in our database.<br /><br />If you think this is wrong <a href="login.php">try again</a>.');
}

while($info = mysqli_fetch_array( $check )){
    $_POST['pass'] = stripslashes($_POST['pass']);
    $info['password'] = stripslashes($info['password']);
    $_POST['pass'] = md5($_POST['pass']);

    //gives error if the password is wrong
    if ($_POST['pass'] != $info['password']){
        die('Incorrect password, please <a href="login.php">try again</a>.');
    }

    else{ // if login is ok then we add a cookie 
        $_POST['username'] = stripslashes($_POST['username']); 
        $hour = time() + 3600; 
        setcookie(ID_your_site, $_POST['username'], $hour); 
        setcookie(Key_your_site, $_POST['pass'], $hour);     

        //then redirect them to the members area 
        header("Location: members.php"); 
    }
}
}
else{
// if they are not logged in 
?>

 <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">  
 <table border="0">  
 <tr><td colspan=2><h1>Login</h1></td></tr>  
 <tr><td>Username:</td><td>  
 <input type="text" name="username" maxlength="40">  
 </td></tr>  
 <tr><td>Password:</td><td>  
 <input type="password" name="pass" maxlength="50">   
 </td></tr> 

 <tr><td colspan="2" align="right">  
 <input type="submit" name="submit" value="Login">  
 </td></tr>  
 </table>  
 </form> 

 <?php 
 }
 ?> 

我在第4行收到错误消息。这是错误消息。

  

无法访问X显示器,是否正确设置了$ DISPLAY?

   1 #!/usr/bin/env python
   2 import wx
   3 
   4 app = wx.App(False)  # Create a new app, don't redirect stdout/stderr to a window.
   5 frame = wx.Frame(None, wx.ID_ANY, "Hello World") # A Frame is a top-level window.
   6 frame.Show(True)     # Show the frame.
   7 app.MainLoop()
  

Linux localhost.localdomain 3.10.0-327.4.5.el7.x86_64#1 SMP Mon Jan   25 22:07:14 UTC 2016 x86_64 x86_64 x86_64 GNU / Linux

 uname -a
  

Python 2.7.5

python --version
  

的wxPython == 2.8.12.0

     

wxPython的共用== 2.8.12.0

1 个答案:

答案 0 :(得分:0)

您可能需要设置X Forwarding才能使其正常运行。 引自@Giles上面的回答:

  

需要在客户端和服务器端启用X11转发。

     

在客户端,-X的{​​{1}}(大写X)选项启用X11转发,您可以将其设置为默认值(对于所有连接或特定连接){{1在~/.ssh/config

     

在服务器端,必须在/etc/ssh/sshd_config中指定ssh。请注意,默认情况下不转发(某些发行版将其默认ForwardX11 yes打开),并且用户无法覆盖此设置。

     

必须在服务器端安装X11Forwarding yes程序。如果那里有任何X11程序,/etc/ssh/sshd_config很可能会在那里。在不太可能的情况下xauth安装在非标准位置,可以通过~/.ssh/rc(在服务器上!)调用它。

     

请注意,您无需在服务器上设置任何环境变量。 xauthxauth会自动设置为正确的值。如果您运行ssh且未设置DISPLAY,则表示ssh未转发X11连接。

     

要确认ssh正在转发X11,请检查XAUTHORITY输出中包含DISPLAY的行。请注意,服务器不会以任何方式回复。