小编Nat*_*ist的帖子

如何让一个python文件运行另一个?

如何制作一个python文件来运行另一个?

例如,我有两个.py文件.我想要运行一个文件,然后让它运行另一个.py文件.

python

274
推荐指数
6
解决办法
53万
查看次数

Android多点触控 - 秒指ACTION.MOVE被忽略

以下代码是我一直尝试用于多点触控的代码.手指一被正确设置并在我拖动手指时四处移动.当我触摸并松开手指时,手指2会显示并消失,但它从不会四处移动.知道什么是错的吗?

我读过开发者博客我仍然不明白问题是什么.

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        int action = event.getAction() & MotionEvent.ACTION_MASK;
        int pointerIndex = (event.getAction() & MotionEvent.ACTION_POINTER_ID_MASK) >> MotionEvent.ACTION_POINTER_ID_SHIFT;
        int pointerId = event.getPointerId(pointerIndex);
        switch (action) {
        case MotionEvent.ACTION_DOWN:
        case MotionEvent.ACTION_POINTER_DOWN:
            if (pointerId == 0)
            {
                fingerOneDown = 1;
                fingerOneX = event.getX(pointerIndex);
                fingerOneY = event.getY(pointerIndex);
            }
            if (pointerId == 1)
            {
                fingerTwoDown = 1;
                fingerTwoX = event.getX(pointerIndex);
                fingerTwoY = event.getY(pointerIndex);
            }
            break;

        case MotionEvent.ACTION_UP:          
        case MotionEvent.ACTION_POINTER_UP:
        case MotionEvent.ACTION_CANCEL:
            if (pointerId == 0)
            {
                fingerOneDown = 0; …
Run Code Online (Sandbox Code Playgroud)

java android multi-touch

20
推荐指数
1
解决办法
9466
查看次数

将ObservableCollection绑定到ListView

我在使数据正确绑定方面遇到了很大的麻烦.我已经从有类似问题的人那里阅读了大部分帖子,但由于某些原因我无法点击它.

我表的XML是:

<Window ... DataContext="{Binding RelativeSource={RelativeSource Self}}" >
...
<ListView Height="124" HorizontalAlignment="Left" Margin="12,46,0,0" Name="listViewDocuments" VerticalAlignment="Top" Width="Auto" DataContext="{Binding DocumentList}">
    <ListView.View>
        <GridView>
            <GridViewColumn Width="160" Header="Description" DisplayMemberBinding="{Binding Description}"/>
            <GridViewColumn Width="160" Header="Date Filed" DisplayMemberBinding="{Binding DateFiled}"/>
            <GridViewColumn Width="160" Header="Filed By" DisplayMemberBinding="{Binding UserFiledName}"/>
            <GridViewColumn Width="150" Header="Page" DisplayMemberBinding="{Binding Pages}"/>
            <GridViewColumn Width="150" Header="Notes" DisplayMemberBinding="{Binding Notes}"/>
            <GridViewColumn Width="Auto" Header="" />
        </GridView>
    </ListView.View>
</ListView>
Run Code Online (Sandbox Code Playgroud)

在我的代码中,我有:

public ObservableCollection<Document> _DocumentList = new ObservableCollection<Document>();

...

public ObservableCollection<Document> DocumentList{ get { return _DocumentList; } }

...

public class Document
{
    public string Description { …
Run Code Online (Sandbox Code Playgroud)

c# data-binding wpf listview observablecollection

7
推荐指数
1
解决办法
2万
查看次数

显示枚举说明而不是名称

我有这样的数据绑定设置:

ItemsSource="{Binding Source={my:Enumeration {x:Type credit:OccupationCategory}}}"
                      DisplayMemberPath="Description"
                      SelectedValue="{Binding EmplType}"
                      SelectedValuePath="Value"/>
Run Code Online (Sandbox Code Playgroud)

它工作得很好.对更大的软件设计进行更改我不能再生成任何生成INotifyPropertyChanged事件的内容,因此数据绑定类型不起作用.相反,我手动设置selectedIndex并从代码构建选项,如下所示:

ItemsSource="{Binding Source={StaticResource ResidenceOwnershipType}}"/>
Run Code Online (Sandbox Code Playgroud)

哪些参考

<UserControl.Resources>
    <ObjectDataProvider x:Key="ResidenceOwnershipType" MethodName="GetValues" ObjectType="{x:Type System:Enum}" >
        <ObjectDataProvider.MethodParameters>
            <x:Type TypeName="credit:ResidenceOwnershipType" />
        </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>
</UserControl.Resources>
Run Code Online (Sandbox Code Playgroud)

就列表选项的构建和所有数据的链接而言,这是有效的,但我无法让组合框在枚举中显示描述标记而不是实际文本.

我尝试过这样的事情:

DisplayMemberPath="Description"
Run Code Online (Sandbox Code Playgroud)

但这不正确.我该怎么做呢?

编辑:

我的枚举:

[DataContract]
public enum ResidenceOwnershipType
{
    [Description("")]
    None = 0,
    [Description("Owns Home Outright")]
    OwnsHomeOutright = 1,
    [Description("Buying Home")]
    BuyingHome = 2,
    [Description("Renting/Leasing")] //Weird order here reflects RouteOne website
    RentingLeasing = 4,
    [Description("Living w/Relatives")]
    LivingWithRelatives = 3,
    [Description("Owns/Buying Mobile Home")]
    MobileHome = 5,
    [Description("Unknown")]
    Unknown = 6
}
Run Code Online (Sandbox Code Playgroud)

c# data-binding wpf enums xaml

6
推荐指数
1
解决办法
1万
查看次数

按钮BackgroundTint不与AppCompat v23一起使用

我正在尝试使用AppCompat v23,以便使用BackgroundTint进行完整的Button着色.

我已经添加compile 'com.android.support:appcompat-v7:23.0.+'到我的应用程序的build.gradle文件中.

我android:theme="@style/AppTheme"在AndroidManifest.xml中设置了我的应用主题

在styles.xml我有:

<resources>
    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light">
        <!-- Customize your theme here. -->
    </style>
</resources>
Run Code Online (Sandbox Code Playgroud)

我不是要覆盖任何东西,我只是想让基本主题起作用.

我public class LandingActivity extends AppCompatActivity在我的主要活动声明中使用.

最后,在布局中我有android:backgroundTint一个Button来设置colors.xml中的颜色.

在运行5.0的设备上,颜色完美运行.在4.0设备上,按钮上没有着色.这是默认的灰色.

我确定我错过了什么,但我不知道它是什么. 我需要采取任何其他步骤才能让AppCompat库发挥其魔力吗?

java android button android-appcompat

6
推荐指数
1
解决办法
4001
查看次数

iOS 9中的强制视图控制器方向

我正在制作一个摄影应用程序,允许以肖像或风景拍摄照片.由于项目的要求,我不能让设备方向自动旋转,但确实需要支持旋转.

使用以下定位方法时:

override func shouldAutorotate() -> Bool {
    return true
}

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    if self.orientation == .Landscape {
        return UIInterfaceOrientationMask.LandscapeRight
    } else {
        return UIInterfaceOrientationMask.Portrait
    }
}

override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
    if self.orientation == .Landscape {
        return UIInterfaceOrientation.LandscapeRight
    } else {
        return UIInterfaceOrientation.Portrait
    }
}
Run Code Online (Sandbox Code Playgroud)

我可以在启动时正确设置旋转.通过更改方向值并调用UIViewController.attemptRotationToDeviceOrientation()我能够支持旋转到新的所需界面.但是,此旋转仅在用户实际移动其设备时发生.我需要它自动发生.

我可以调用:UIDevice.currentDevice().setValue(targetOrientation.rawValue, forKey: "orientation")强制更改,但这会导致其他副作用,因为UIDevice.currentDevice().orientation只返回该点的setValue.(而且非常脏)

有什么我想念的吗?我已经研究过关闭并启动一个新的视图控制器,但这有其他问题,例如在解除时立即出现UI故障并立即呈现新的视图控制器.

编辑:

以下方法对我不起作用:

编辑2:

对潜在解决方案的思考

  1. 直接设置方向(带setValue)并处理iOS 9上出现的所有副作用(不可接受)

  2. 我可以使用当前的解决方案并指示用户需要旋转设备.设备物理旋转后,UI会旋转,然后正确锁定到位.(差的UI)

  3. 我可以找到一种解决方案,强制刷新方向并在没有物理操作的情况下旋转.(我在问什么,并寻找)

  4. 手工完成所有工作.我可以纵向或横向锁定界面,并手动旋转和调整容器视图的大小.这是"脏"的,因为它放弃了所有大小类自动布局功能,并导致更重的代码.我试图避免这种情况.

iphone uiinterfaceorientation ios

6
推荐指数
1
解决办法
8826
查看次数

Application.DoEvents()的替代方案

我正在开发一个基于webBrowser控件的消息传递系统,这样我就可以格式化文本了.当用户离线并发送消息时,将存储消息并在重新登录时为每条消息发送事件.当我为网站设置默认html等时,我通常使用:

while (this.webBrowser1.ReadyState != WebBrowserReadyState.Complete) Application.DoEvents();
Run Code Online (Sandbox Code Playgroud)

这在程序正常运行时有效.当用户正在接收他们离线时发送的消息时,这将触发下一个消息事件,依此类推,每个消息一直到最后一个消息.这意味着它们脱机时发送的最后一条消息是唯一显示的消息.我想像Application.DoEvents()这样的东西允许控件不断更新和加载,但这不会触发其他事件.

谢谢

编辑:

我通过完全删除DoEvents()来解决问题.我没有像我工作那样更改DocumentText,而是设置了一个字符串构建器,然后在最后设置html all.

c# browser messaging doevents winforms

5
推荐指数
1
解决办法
2万
查看次数

Android多点触控 - 确定哪个手指抬起?

我理解ID和索引之间的区别,看起来ID在事件中是一致的,索引可以变化.

但是,我一直在改变ID,我正在寻找这个领域的一些理解.我已阅读所有官方的Android文档和众多博客,但似乎没有一个简洁的答案.

如果我在屏幕上放置三根手指,则会有ID为0,1和2.只要这些手指在屏幕上,这些ID就会保持不变.正确?

一旦手指抬起,比如说第二根手指,跟踪点保持不变.在x0,y0和x1,y1处仍有一个点,但ID现在为0和1.即使ID号为1的点被抬起.

有没有办法看到手指#2抬起,并使用ID 0和ID 2跟踪点?

我的理解是,这需要手动完成,并且ID值将保持相同的顺序,其中放置的第二个手指始终具有比第一个更高的ID,但是当手指被移除时它们可能不会保持相同的值.

java android multi-touch

5
推荐指数
1
解决办法
444
查看次数

C - fscanf混合数和静态文本

我试图读取以这种一般方式格式化的文件:

Text Description: 12
Description2: 1
More descriptive things: 6
Run Code Online (Sandbox Code Playgroud)

我想把数字12,1和6读成变量.

我试过这样的代码:

fscanf(fptr, "Text Description:%d",&desc1);
fscanf(fptr, "Description2:%d",&desc2);
fscanf(fptr, "More descriptive things:%d",&desc3);
Run Code Online (Sandbox Code Playgroud)

但由于某种原因,只有第一个变量被填充.有谁知道为什么会这样?

c scanf

5
推荐指数
1
解决办法
461
查看次数

根据可用库更改程序流程

我正在开发一个Python模型,如果安装了正确的模块,它将支持图形化.我希望源代码尽可能相同,IE,如果图形模型无法加载,图形将从菜单逻辑中忽略.

我怎么能做到这一点?

python graph matplotlib

4
推荐指数
1
解决办法
161
查看次数